Exemplo n.º 1
0
        public async Task Should_Success_Update()
        {
            var serviceProvider = GetServiceProvider();
            NewFpRegradingResultDocsService serviceMrn = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            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);
            var mrn = await _dataUtilMrn(serviceMrn).GetTestData();

            serviceProvider.Setup(x => x.GetService(typeof(IFpRegradingResultDocsService)))
            .Returns(serviceMrn);
            NewFPReturnInvToPurchasingService service = new NewFPReturnInvToPurchasingService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = await _dataUtil(service, serviceMrn).GetTestData();

            var vm       = service.MapToViewModel(data);
            var testData = service.MapToModel(vm);

            testData.FPReturnInvToPurchasingDetails.Add(new Lib.Models.FPReturnInvToPurchasingModel.FPReturnInvToPurchasingDetail()
            {
            });
            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(vm);

            testData2.FPReturnInvToPurchasingDetails.Clear();
            var newResponse = await service.UpdateAsync(testData2.Id, testData2);

            Assert.NotEqual(0, newResponse);
        }
Exemplo n.º 2
0
        public void Should_Success_MapToModel()
        {
            var serviceProvider = GetServiceProvider();
            NewFpRegradingResultDocsService   serviceMrn = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            NewFPReturnInvToPurchasingService service    = new NewFPReturnInvToPurchasingService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = _dataUtil(service, serviceMrn).GetEmptyData();


            var model = service.MapToModel(data);

            Assert.NotNull(model);
        }