public async Task GetReport_Return_Ok() { //Setup Mock <IServiceProvider> serviceProviderMock = GetServiceProvider(); var service = new Mock <IGarmentDispositionExpeditionService>(); var paymentService = new Mock <IGarmentDispositionPaymentReportService>(); paymentService .Setup(s => s.GetReport(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <GarmentPurchasingExpeditionPosition>(), It.IsAny <string>(), It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>())) .ReturnsAsync(new List <GarmentDispositionPaymentReportDto> { new GarmentDispositionPaymentReportDto(0, "test", DateTimeOffset.MinValue, DateTimeOffset.MinValue, null, 0, null, null, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, null, GarmentPurchasingExpeditionPosition.AccountingAccepted, null, DateTimeOffset.MinValue, DateTimeOffset.MinValue, null, DateTimeOffset.MinValue, null, null, "0", 0, null, 0, 0, null, 0, null, null, 0, null, DateTimeOffset.MinValue, 0, null, 0, null, DateTimeOffset.MinValue, null, DateTimeOffset.MinValue, null, null) }); serviceProviderMock .Setup(serviceProvider => serviceProvider.GetService(typeof(IGarmentDispositionExpeditionService))) .Returns(service.Object); //Act RejectionForm form = new RejectionForm(); IActionResult response = await GetController(serviceProviderMock).GetReport(0, 0, GarmentPurchasingExpeditionPosition.AccountingAccepted, string.Empty, null, null); //Assert //int statusCode = this.GetStatusCode(response); Assert.NotNull(response); }
public async Task SendToPurchasingRejected_Return_InternalServerError() { //Setup Mock <IServiceProvider> serviceProviderMock = GetServiceProvider(); var service = new Mock <IGarmentDispositionExpeditionService>(); service .Setup(s => s.SendToPurchasingRejected(It.IsAny <int>(), It.IsAny <string>())) .ThrowsAsync(new Exception()); serviceProviderMock .Setup(serviceProvider => serviceProvider.GetService(typeof(IGarmentDispositionExpeditionService))) .Returns(service.Object); //Act RejectionForm form = new RejectionForm(); IActionResult response = await GetController(serviceProviderMock).SendToPurchasingRejected(1, form);; //Assert int statusCode = this.GetStatusCode(response); Assert.Equal((int)HttpStatusCode.InternalServerError, statusCode); }
public async Task GetReport_Return_InternalServerError() { //Setup Mock <IServiceProvider> serviceProviderMock = GetServiceProvider(); var service = new Mock <IGarmentDispositionExpeditionService>(); var paymentService = new Mock <IGarmentDispositionPaymentReportService>(); paymentService .Setup(s => s.GetReport(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <GarmentPurchasingExpeditionPosition>(), It.IsAny <string>(), It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>())) .ThrowsAsync(new Exception("test failed")); serviceProviderMock .Setup(serviceProvider => serviceProvider.GetService(typeof(IGarmentDispositionExpeditionService))) .Returns(service.Object); //Act RejectionForm form = new RejectionForm(); IActionResult response = await GetController(serviceProviderMock).GetReport(0, 0, GarmentPurchasingExpeditionPosition.AccountingAccepted, string.Empty, null, null); //Assert int statusCode = this.GetStatusCode(response); Assert.Equal((int)HttpStatusCode.InternalServerError, statusCode); }