public async Task Should_Success_Update() { var serviceProvider = GetServiceProvider(); 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); NewFpRegradingResultDocsService service = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod())); var data = await _dataUtil(service).GetTestData(); var vm = service.MapToViewModel(data); var testData = service.MapToModel(vm); testData.Details.Add(new FpRegradingResultDocsDetails { Grade = "a", Length = 12, ProductCode = "code", ProductId = "1", ProductName = "name", Quantity = 1, Remark = "remar", Retur = "retur" }); 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(vm2); testData2.Details.Clear(); var newResponse = await service.UpdateAsync(testData2.Id, testData2); Assert.NotEqual(0, newResponse); }
public void Should_Success_MapToModel() { NewFpRegradingResultDocsService service = new NewFpRegradingResultDocsService(GetFailServiceProvider().Object, _dbContext(GetCurrentMethod())); var data = _dataUtil(service).GetEmptyData(); var model = service.MapToModel(data); Assert.NotNull(model); }