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); NewStockTransferNoteService service = new NewStockTransferNoteService(serviceProvider.Object, _dbContext(GetCurrentMethod())); var data = await _dataUtil(service).GetTestData(); var vm = service.MapToViewModel(data); var testData = service.MapToModel(vm); testData.StockTransferNoteItems.Add(new Lib.Models.StockTransferNoteModel.StockTransferNote_Item { ProductCode = "code", ProductId = "1", ProductName = "name", StockQuantity = 2, TransferedQuantity = 2, UomId = "2", UomUnit = "unitA" }); testData.TargetStorageName = "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.StockTransferNoteItems.Clear(); var newResponse = await service.UpdateAsync(testData2.Id, testData2); Assert.NotEqual(0, newResponse); }
public void Should_Success_MapToModel() { NewStockTransferNoteService service = new NewStockTransferNoteService(GetFailServiceProvider().Object, _dbContext(GetCurrentMethod())); var data = _dataUtil(service).GetNewData(); var vm = service.MapToViewModel(data); var model = service.MapToModel(vm); Assert.NotNull(model); }