public async Task Should_Success_MapToViewModel() { MaterialRequestNoteRepository repositoryMrn = new MaterialRequestNoteRepository(serviceProvider.Object, inventoryDbContext); InventorySummaryRepository InventorySummaryRepository = new InventorySummaryRepository(serviceProvider.Object, inventoryDbContext); serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryRepository))) .Returns(InventorySummaryRepository); InventoryMovementRepository InventoryMovementRepository = new InventoryMovementRepository(serviceProvider.Object, inventoryDbContext); serviceProvider.Setup(s => s.GetService(typeof(IInventoryMovementRepository))) .Returns(InventoryMovementRepository); InventoryDocumentRepository inventoryDocumentRepository = new InventoryDocumentRepository(serviceProvider.Object, inventoryDbContext); serviceProvider.Setup(s => s.GetService(typeof(IInventoryDocumentRepository))) .Returns(inventoryDocumentRepository); var mrn = await DataUtilMrn(repositoryMrn).GetTestData(); serviceProvider.Setup(x => x.GetService(typeof(IMaterialRequestNoteRepository))) .Returns(repositoryMrn); MaterialDistributionNoteRepository repository = new MaterialDistributionNoteRepository(serviceProvider.Object, inventoryDbContext); var data = await DataUtil(repository, repositoryMrn).GetTestData(); var model = repository.MapToViewModel(data); Assert.NotNull(model); }
public async Task Should_Success_ValidateVM() { MaterialRequestNoteRepository repositoryMrn = new MaterialRequestNoteRepository(serviceProvider.Object, inventoryDbContext); InventorySummaryRepository InventorySummaryRepository = new InventorySummaryRepository(serviceProvider.Object, inventoryDbContext); serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryRepository))) .Returns(InventorySummaryRepository); await InventorySummaryRepository.Create(new InventorySummary() { StorageName = "Warehouse Here Finishing", UomUnit = "MTR", ProductCode = "Code", Quantity = 1 }); InventoryMovementRepository InventoryMovementRepository = new InventoryMovementRepository(serviceProvider.Object, inventoryDbContext); serviceProvider.Setup(s => s.GetService(typeof(IInventoryMovementRepository))) .Returns(InventoryMovementRepository); InventoryDocumentRepository inventoryDocumentRepository = new InventoryDocumentRepository(serviceProvider.Object, inventoryDbContext); serviceProvider.Setup(s => s.GetService(typeof(IInventoryDocumentRepository))) .Returns(inventoryDocumentRepository); serviceProvider.Setup(x => x.GetService(typeof(IMaterialRequestNoteRepository))) .Returns(repositoryMrn); MaterialDistributionNoteRepository repository = new MaterialDistributionNoteRepository(serviceProvider.Object, inventoryDbContext); var data = await DataUtil(repository, repositoryMrn).GetTestData(); var vm = repository.MapToViewModel(data); ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null); var response = vm.Validate(InventorySummaryRepository.GetByStorageAndMTR); Assert.True(response.Count() == 0); }
public async Task Should_Success_Update() { MaterialRequestNoteRepository repositoryMrn = new MaterialRequestNoteRepository(serviceProvider.Object, inventoryDbContext); InventorySummaryRepository InventorySummaryRepository = new InventorySummaryRepository(serviceProvider.Object, inventoryDbContext); serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryRepository))) .Returns(InventorySummaryRepository); InventoryMovementRepository InventoryMovementRepository = new InventoryMovementRepository(serviceProvider.Object, inventoryDbContext); serviceProvider.Setup(s => s.GetService(typeof(IInventoryMovementRepository))) .Returns(InventoryMovementRepository); InventoryDocumentRepository inventoryDocumentRepository = new InventoryDocumentRepository(serviceProvider.Object, inventoryDbContext); serviceProvider.Setup(s => s.GetService(typeof(IInventoryDocumentRepository))) .Returns(inventoryDocumentRepository); var mrn = await DataUtilMrn(repositoryMrn).GetTestData(); serviceProvider.Setup(x => x.GetService(typeof(IMaterialRequestNoteRepository))) .Returns(repositoryMrn); MaterialDistributionNoteRepository repository = new MaterialDistributionNoteRepository(serviceProvider.Object, inventoryDbContext); var data = await DataUtil(repository, repositoryMrn).GetTestData(); var vm = repository.MapToViewModel(data); var testData = repository.MapToModel(vm); testData.MaterialDistributionNoteItems.Add(new MaterialDistributionNoteItem() { MaterialDistributionNoteDetails = new List <MaterialDistributionNoteDetail>() { new MaterialDistributionNoteDetail() } }); testData.UnitName = "a"; var response = await repository.UpdateAsync(testData.Id, testData); Assert.NotEqual(0, response); var newData3 = await repository.ReadByIdAsync(data.Id); var vm3 = repository.MapToViewModel(newData3); var testData3 = repository.MapToModel(vm); var dItem = testData3.MaterialDistributionNoteItems.FirstOrDefault(); dItem.MaterialDistributionNoteDetails = new List <MaterialDistributionNoteDetail>() { new MaterialDistributionNoteDetail() { } }; var newResponse3 = await repository.UpdateAsync(testData3.Id, testData3); Assert.NotEqual(0, newResponse3); var newData = await repository.ReadByIdAsync(data.Id); var vm2 = repository.MapToViewModel(newData); var testData2 = repository.MapToModel(vm); testData2.MaterialDistributionNoteItems.Clear(); var newResponse = await repository.UpdateAsync(testData2.Id, testData2); Assert.NotEqual(0, newResponse); }