public async Task Should_Success_CreateAsync() { 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 = _dataUtil(service, serviceMrn).GetNewData(); foreach (var item in data.FPReturnInvToPurchasingDetails) { item.FPRegradingResultDocsCode = mrn.Code; item.FPRegradingResultDocsId = mrn.Id; } var Response = await service.CreateAsync(data); Assert.NotEqual(0, Response); }
public async Task Should_Fail_CreateAsync() { var serviceProvider = GetServiceProvider(); NewFpRegradingResultDocsService serviceMrn = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod())); NewFPReturnInvToPurchasingService service = new NewFPReturnInvToPurchasingService(serviceProvider.Object, _dbContext(GetCurrentMethod())); var data = _dataUtil(service, serviceMrn).GetNewData(); await Assert.ThrowsAnyAsync <Exception>(() => service.CreateAsync(data)); }