diff --git a/AsbCloudWebApi.Tests/ControllersTests/AnalyticsControllerTests.cs b/AsbCloudWebApi.Tests/ControllersTests/AnalyticsControllerTests.cs index 9fb78ddc..1b82bd74 100644 --- a/AsbCloudWebApi.Tests/ControllersTests/AnalyticsControllerTests.cs +++ b/AsbCloudWebApi.Tests/ControllersTests/AnalyticsControllerTests.cs @@ -7,6 +7,7 @@ using Moq; using System; using System.Collections.Generic; using System.Security.Claims; +using System.Threading; using Xunit; namespace AsbCloudWebApi.Tests.ControllersTests @@ -31,7 +32,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests new WellDepthToDayDto { WellDepth = 3000.0, BitDepth = 3000.0, Date = DateTime.Now } }; - analyticsService.Setup(s => s.GetWellDepthToDay(It.IsAny())) + analyticsService.Setup(s => s.GetWellDepthToDayAsync(It.IsAny(), CancellationToken.None).Result) .Returns(depthToDayDtos); wellService.Setup(s => s.IsCompanyInvolvedInWell(It.IsAny(), It.IsAny())) @@ -54,7 +55,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests [Fact] public void It_should_return_depth_to_day_analytics() { - var result = controller.GetWellDepthToDay(1); + var result = controller.GetWellDepthToDayAsync(1).Result; var okResult = result as OkObjectResult; Assert.NotNull(okResult); @@ -63,7 +64,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests [Fact] public void It_should_return_correct_count_depth_to_day_analytics() { - var result = controller.GetWellDepthToDay(1); + var result = controller.GetWellDepthToDayAsync(1).Result; var okResult = result as OkObjectResult; var resultCount = ((List)okResult.Value).Count; @@ -83,7 +84,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests HttpContext = new DefaultHttpContext() { User = user } }; - var result = emptyUserController.GetWellDepthToDay(1); + var result = emptyUserController.GetOperationsByWellAsync(1).Result; var forbidResult = result as ForbidResult; Assert.NotNull(forbidResult); @@ -110,7 +111,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests HttpContext = new DefaultHttpContext() { User = user } }; - var result = newControllerInstance.GetWellDepthToDay(1); + var result = newControllerInstance.GetWellDepthToDayAsync(1).Result; var forbidResult = result as ForbidResult; Assert.NotNull(forbidResult); @@ -121,7 +122,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests { var emptyAnalyticsService = new Mock(); - emptyAnalyticsService.Setup(s => s.GetWellDepthToDay(It.IsAny())) + emptyAnalyticsService.Setup(s => s.GetWellDepthToDayAsync(It.IsAny(), CancellationToken.None).Result) .Returns(new List()); var newControllerInstance = new TelemetryAnalyticsController(emptyAnalyticsService.Object, @@ -137,7 +138,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests HttpContext = new DefaultHttpContext() { User = user } }; - var result = newControllerInstance.GetWellDepthToDay(1); + var result = newControllerInstance.GetWellDepthToDayAsync(1).Result; var notFoundResult = result as NoContentResult; Assert.NotNull(notFoundResult); @@ -148,7 +149,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests { var emptyAnalyticsService = new Mock(); - emptyAnalyticsService.Setup(s => s.GetWellDepthToDay(It.IsAny())) + emptyAnalyticsService.Setup(s => s.GetWellDepthToDayAsync(It.IsAny(), CancellationToken.None).Result) .Returns(value: null); var newControllerInstance = new TelemetryAnalyticsController(emptyAnalyticsService.Object, @@ -164,7 +165,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests HttpContext = new DefaultHttpContext() { User = user } }; - var result = newControllerInstance.GetWellDepthToDay(1); + var result = newControllerInstance.GetWellDepthToDayAsync(1).Result; var notFoundResult = result as NoContentResult; Assert.NotNull(notFoundResult); diff --git a/ConsoleApp1/DebugWellOperationsStatService.cs b/ConsoleApp1/DebugWellOperationsStatService.cs index 73a311cf..4d826145 100644 --- a/ConsoleApp1/DebugWellOperationsStatService.cs +++ b/ConsoleApp1/DebugWellOperationsStatService.cs @@ -16,16 +16,16 @@ namespace ConsoleApp1 { public static void Main(/*string[] args*/) { - var options = new DbContextOptionsBuilder() - .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") - .Options; - using var db = new AsbCloudDbContext(options); - var cacheDb = new CacheDb(); - var telemetryService = new TelemetryService(db, new TelemetryTracker(cacheDb), cacheDb); - var wellService = new WellService(db, telemetryService, cacheDb); - var wellOptsStat = new OperationsStatService(db, cacheDb, wellService); - var tvd = wellOptsStat.GetTvdAsync(1, default).Result; - Print(tvd); + //var options = new DbContextOptionsBuilder() + // .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") + // .Options; + //using var db = new AsbCloudDbContext(options); + //var cacheDb = new CacheDb(); + //var telemetryService = new TelemetryService(db, new TelemetryTracker(cacheDb), cacheDb); + //var wellService = new WellService(db, telemetryService, cacheDb); + //var wellOptsStat = new OperationsStatService(db, cacheDb, wellService); + //var tvd = wellOptsStat.GetTvdAsync(1, default).Result; + //Print(tvd); } private static void Print(IEnumerable> tvd)