public async Task Should_Success_ReadById() { var serviceProvider = GetServiceProvider(); NewFpRegradingResultDocsService serviceMrn = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod())); InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod())); serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService))) .Returns(inventorySummaryService); InventoryMovementService inventoryMovementService = new InventoryMovementService(serviceProvider.Object, _dbContext(GetCurrentMethod())); serviceProvider.Setup(s => s.GetService(typeof(IInventoryMovementService))) .Returns(inventoryMovementService); InventoryDocumentService inventoryDocumentFacade = new InventoryDocumentService(serviceProvider.Object, _dbContext(GetCurrentMethod())); serviceProvider.Setup(s => s.GetService(typeof(IInventoryDocumentService))) .Returns(inventoryDocumentFacade); var mrn = await _dataUtilMrn(serviceMrn).GetTestData(); serviceProvider.Setup(x => x.GetService(typeof(IFpRegradingResultDocsService))) .Returns(serviceMrn); NewFPReturnInvToPurchasingService service = new NewFPReturnInvToPurchasingService(serviceProvider.Object, _dbContext(GetCurrentMethod())); var data = await _dataUtil(service, serviceMrn).GetTestData(); var model = await service.ReadByIdAsync(data.Id); Assert.NotNull(model); }
public async Task Should_Success_Update() { var serviceProvider = GetServiceProvider(); NewFpRegradingResultDocsService serviceMrn = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod())); InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod())); serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService))) .Returns(inventorySummaryService); InventoryMovementService inventoryMovementService = new InventoryMovementService(serviceProvider.Object, _dbContext(GetCurrentMethod())); serviceProvider.Setup(s => s.GetService(typeof(IInventoryMovementService))) .Returns(inventoryMovementService); InventoryDocumentService inventoryDocumentFacade = new InventoryDocumentService(serviceProvider.Object, _dbContext(GetCurrentMethod())); serviceProvider.Setup(s => s.GetService(typeof(IInventoryDocumentService))) .Returns(inventoryDocumentFacade); var mrn = await _dataUtilMrn(serviceMrn).GetTestData(); serviceProvider.Setup(x => x.GetService(typeof(IFpRegradingResultDocsService))) .Returns(serviceMrn); NewFPReturnInvToPurchasingService service = new NewFPReturnInvToPurchasingService(serviceProvider.Object, _dbContext(GetCurrentMethod())); var data = await _dataUtil(service, serviceMrn).GetTestData(); var vm = service.MapToViewModel(data); var testData = service.MapToModel(vm); testData.FPReturnInvToPurchasingDetails.Add(new Lib.Models.FPReturnInvToPurchasingModel.FPReturnInvToPurchasingDetail() { }); testData.UnitName = "a"; var response = await service.UpdateAsync(testData.Id, testData); Assert.NotEqual(0, response); var newData = await service.ReadByIdAsync(data.Id); var vm2 = service.MapToViewModel(newData); var testData2 = service.MapToModel(vm); testData2.FPReturnInvToPurchasingDetails.Clear(); var newResponse = await service.UpdateAsync(testData2.Id, testData2); Assert.NotEqual(0, newResponse); }