public async Task Should_Fail_CreateAsync() { var serviceProvider = GetServiceProvider(); InventorySummaryService service = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod())); var data = _dataUtil(service).GetNewData(); await Assert.ThrowsAnyAsync <Exception>(() => service.Create(null)); }
public async Task <InventorySummary> GetTestData() { InventorySummary invSum = GetNewData(); await Service.Create(invSum); return(invSum); }
public async Task Should_Success_CreateAsync() { var serviceProvider = GetServiceProvider(); InventorySummaryService service = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod())); var data = _dataUtil(service).GetNewData(); var Response = await service.Create(data); Assert.NotEqual(0, Response); }
public async Task Should_Success_ReadId() { var serviceProvider = GetServiceProvider(); InventorySummaryService service = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod())); var data = await _dataUtil(service).GetTestData(); var data2 = _dataUtil(service).GetNewData(); var Response = await service.Create(data2); var models = service.Read(1, 25, "{}", null, "{}"); var single = models.Data.FirstOrDefault(); var model = service.ReadModelById(single.Id); Assert.NotNull(model); }
public async Task ValidateVM_ReceivedLength_lessThan_stock() { var serviceProvider = GetServiceProvider(); NewMaterialRequestNoteService serviceMrn = new NewMaterialRequestNoteService(serviceProvider.Object, _dbContext(GetCurrentMethod())); InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod())); serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService))) .Returns(inventorySummaryService); await inventorySummaryService.Create(new Lib.Models.InventoryModel.InventorySummary() { StorageName = "Gudang Greige Finishing", UomUnit = "MTR", ProductCode = "code", Quantity = 0 }); 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); serviceProvider.Setup(x => x.GetService(typeof(IMaterialRequestNoteService))) .Returns(serviceMrn); //serviceProvider.Setup(s => s.GetService(typeof(InventoryDocumentFacade))) // .Returns(inventoryDocumentFacade); NewMaterialDistributionNoteService service = new NewMaterialDistributionNoteService(serviceProvider.Object, _dbContext(GetCurrentMethod())); var data = await _dataUtil(service, serviceMrn).GetTestData(); var vm = service.MapToViewModel(data); ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null); var response = vm.Validate(validationContext); Assert.True(response.Count() > 0); }