示例#1
0
        public async void PostUserSimple_Ok()
        {
            // Arrange
            var mockLoggingService = new Mock <IDatabaseAccessService>();

            mockLoggingService.Setup(service => service.LogUserAsync(It.IsAny <UserInfoBaseRequestBody>()))
            .ReturnsAsync(new FullUserInfo());
            var mockRevenueForecastService = new Mock <IRevenueForecastService>();

            mockRevenueForecastService.Setup(service => service.StartCalculationAsync(It.IsAny <FullUserInfo>()))
            .ReturnsAsync(new RevenueForecasts());
            var mockExportService = new Mock <IForecastExportService>();
            var controller        = new RevenueForecastController(mockLoggingService.Object, mockRevenueForecastService.Object, _mapper, mockExportService.Object);

            // Act
            var requestBody = new UserInfoBaseRequestBody
            {
                Email = "123"
            };
            var result = await controller.PostUserSimpleAsync(requestBody);

            // Assert
            if (result is OkObjectResult objectResult)
            {
                Assert.IsType <RevenueForecastViewModel>(objectResult.Value as RevenueForecastViewModel);
            }
            else
            {
                Assert.True(false, "failed to receive revenue forecast as result");
            }
        }
示例#2
0
        public async Task GetRevenueForecast_NotFound()
        {
            // Arrange
            var mockLoggingService = new Mock <IDatabaseAccessService>();

            mockLoggingService.Setup(service => service.GetForecastAsync(It.IsAny <string>()))
            .Throws(new ItemNotFoundException("Entity"));
            var mockRevenueForecastService = new Mock <IRevenueForecastService>();
            var mockExportService          = new Mock <IForecastExportService>();
            var controller = new RevenueForecastController(mockLoggingService.Object, mockRevenueForecastService.Object, _mapper, mockExportService.Object);

            // Act & Assert
            await Assert.ThrowsAsync <ItemNotFoundException>(() => controller.GetForecast("123"));
        }
示例#3
0
        public async void GetRevenueForecast_Ok()
        {
            // Arrange
            var mockLoggingService = new Mock <IDatabaseAccessService>();

            mockLoggingService.Setup(service => service.GetForecastAsync(It.IsAny <string>()))
            .ReturnsAsync(new RevenueForecasts());
            var mockRevenueForecastService = new Mock <IRevenueForecastService>();
            var mockExportService          = new Mock <IForecastExportService>();
            var controller = new RevenueForecastController(mockLoggingService.Object, mockRevenueForecastService.Object, _mapper, mockExportService.Object);

            // Act
            var result = await controller.GetForecast("123");

            // Assert
            if (result is OkObjectResult objectResult)
            {
                Assert.IsType <RevenueForecastViewModel>(objectResult.Value as RevenueForecastViewModel);
            }
            else
            {
                Assert.True(false, "failed to receive revenue forecast as result");
            }
        }