Exemplo n.º 1
0
        public void Should_Success_MapToModel()
        {
            MaterialRequestNoteRepository      repositoryMrn = new MaterialRequestNoteRepository(serviceProvider.Object, inventoryDbContext);
            MaterialDistributionNoteRepository repository    = new MaterialDistributionNoteRepository(serviceProvider.Object, inventoryDbContext);
            var data = DataUtil(repository, repositoryMrn).GetEmptyData();


            var model = repository.MapToModel(data);

            Assert.NotNull(model);
        }
Exemplo n.º 2
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);
        }