예제 #1
0
        public async Task Should_Success_CreateAsync()
        {
            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 = _dataUtil(service, serviceMrn).GetNewData();

            foreach (var item in data.FPReturnInvToPurchasingDetails)
            {
                item.FPRegradingResultDocsCode = mrn.Code;
                item.FPRegradingResultDocsId   = mrn.Id;
            }
            var Response = await service.CreateAsync(data);

            Assert.NotEqual(0, Response);
        }
예제 #2
0
        public async Task Should_Success_ValidateVM()
        {
            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);
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);
            var response = vm.Validate(validationContext);

            Assert.True(response.Count() == 0);
        }
예제 #3
0
        public async Task Should_Success_ValidateNullDetailVMAsync()
        {
            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 vm = new FPReturnInvToPurchasingViewModel()
            {
                FPReturnInvToPurchasingDetails = new List <FPReturnInvToPurchasingDetailViewModel>()
                {
                    new FPReturnInvToPurchasingDetailViewModel()
                }
            };
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);
            var response = vm.Validate(validationContext);

            Assert.True(response.Count() > 0);
        }
예제 #4
0
        public async Task Should_Success_ReadById()
        {
            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 model = await service.ReadByIdAsync(data.Id);

            Assert.NotNull(model);
        }
        public async Task Should_Success_ReadById()
        {
            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);

            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(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 model = await service.ReadByIdAsync(data.Id);

            Assert.NotNull(model);
        }
        public async Task Should_Success_CreateAsync()
        {
            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);

            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(IMaterialRequestNoteService)))
            .Returns(serviceMrn);
            NewMaterialDistributionNoteService service = new NewMaterialDistributionNoteService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = _dataUtil(service, serviceMrn).GetNewData();

            foreach (var item in data.MaterialDistributionNoteItems)
            {
                item.MaterialRequestNoteId             = mrn.Id;
                item.MaterialRequestNoteCreatedDateUtc = mrn._CreatedUtc;
                item.MaterialRequestNoteCode           = mrn.Code;
            }
            var Response = await service.CreateAsync(data);

            Assert.NotEqual(0, Response);
        }
        public async Task Should_Success_ValidateNullVMAsync()
        {
            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);

            NewFpRegradingResultDocsService service = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var vm = new FpRegradingResultDocsViewModel()
            {
                Details = new List <FpRegradingResultDetailsDocsViewModel>()
            };
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);
            var response = vm.Validate(validationContext);

            Assert.True(response.Count() > 0);
        }
        public async Task Should_Success_UpdateIsApprove()
        {
            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);

            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(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 response = service.UpdateIsApprove(new List <int>()
            {
                data.Id
            });

            Assert.True(response);
        }
        public async Task Should_Success_UpdateIsReturnedToPurchasing()
        {
            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);

            NewFpRegradingResultDocsService service = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = await _dataUtil(service).GetTestData();

            var response = service.UpdateIsReturnedToPurchasing(data.Id, true);

            Assert.NotEqual(0, response);
        }
        public async Task CustomCodeGenerator()
        {
            var serviceProvider          = GetServiceProvider();
            InventoryDbContext dbContext = _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);


            NewFpRegradingResultDocsService service = new NewFpRegradingResultDocsService(serviceProvider.Object, dbContext);
            var data = await _dataUtil(service).GetTestData();

            var result = service.CustomCodeGenerator(data);

            Assert.NotNull(result);
        }
예제 #11
0
        public void Should_Success_ValidateNullDetailVM()
        {
            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 service = new InventoryDocumentService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var vm = new InventoryDocumentViewModel()
            {
                items = new List <InventoryDocumentItemViewModel>()
                {
                    new InventoryDocumentItemViewModel()
                }
            };
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);
            var response = vm.Validate(validationContext);

            Assert.True(response.Count() > 0);
        }
        public void Should_Success_ValidateNullDetailVM()
        {
            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);

            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 vm = new MaterialDistributionNoteViewModel()
            {
                MaterialDistributionNoteItems = new List <MaterialDistributionNoteItemViewModel>()
                {
                    new MaterialDistributionNoteItemViewModel()
                }
            };
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);
            var response = vm.Validate(validationContext);

            Assert.True(response.Count() > 0);
        }
예제 #13
0
        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 void Should_Success_GenerateExcel_with_Empty_Data()
        {
            var serviceProvider = GetServiceProvider();

            InventorySummaryService service = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod()));

            var Response = service.GenerateExcel(null, null, 7);

            Assert.NotNull(Response);
        }
예제 #15
0
        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);
        }
예제 #16
0
        public void Should_Success_GetReport()
        {
            var serviceProvider = GetServiceProvider();

            InventorySummaryService service = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = _dataUtil(service).GetTestData();

            var Response = service.GetReport(null, null, 1, 25, "{}", 7);

            Assert.NotNull(Response);
        }
예제 #17
0
        public async Task Should_Success_Read()
        {
            var serviceProvider = GetServiceProvider();

            InventorySummaryService service = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = await _dataUtil(service).GetTestData();

            var model = service.Read(1, 25, "{}", null, "{}");

            Assert.NotNull(model);
        }
예제 #18
0
        public void Should_Success_MapToModel()
        {
            var serviceProvider = GetServiceProvider();

            InventorySummaryService service = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = _dataUtil(service).GetNewDataViewModel();


            var model = service.MapToModel(data);

            Assert.NotNull(model);
        }
예제 #19
0
        public void Validate_When_TransferedQuantity_is_Greater_Than_Stock()
        {
            //Setup
            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 vm = new StockTransferNoteViewModel()
            {
                StockTransferNoteItems = new List <StockTransferNote_ItemViewModel>()
                {
                    new StockTransferNote_ItemViewModel()
                    {
                        Summary = new InventorySummaryViewModel()
                        {
                            productId   = 1,
                            productName = "productName",
                            quantity    = 1
                        },
                        TransferedQuantity = 2
                    },
                    new StockTransferNote_ItemViewModel()
                    {
                        Summary = new InventorySummaryViewModel()
                        {
                            productId   = 1,
                            productName = "productName"
                        },
                    }
                }
            };
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);

            //Act
            var response = vm.Validate(validationContext);

            //Assert
            Assert.True(response.Count() > 0);
        }
예제 #20
0
        public void Validate_MaterialRequestNote_when_Quantity_isNull()
        {
            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);

            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 vm = new MaterialDistributionNoteViewModel()
            {
                Unit = new UnitViewModel()
                {
                    Code = "code",
                    Name = "PRINTING"
                },
                MaterialDistributionNoteItems = new List <MaterialDistributionNoteItemViewModel>()
                {
                    new MaterialDistributionNoteItemViewModel()
                    {
                        MaterialRequestNoteCode         = "MaterialRequestNoteCode",
                        MaterialDistributionNoteDetails = new List <MaterialDistributionNoteDetailViewModel>()
                        {
                            new MaterialDistributionNoteDetailViewModel()
                            {
                                Product        = new ProductViewModel(),
                                ReceivedLength = 1,
                            }
                        }
                    }
                }
            };
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);
            var response = vm.Validate(validationContext);

            Assert.True(response.Count() > 0);
        }
예제 #21
0
        public async Task Should_Success_GetSummaryByParam()
        {
            var serviceProvider = GetServiceProvider();

            InventorySummaryService service = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = await _dataUtil(service).GetTestData();

            var models = service.Read(1, 25, "{}", null, "{}");
            var single = models.Data.FirstOrDefault();
            var model  = service.GetSummaryByParams(single.StorageId, single.ProductId, single.UomId);

            Assert.NotNull(model);
        }
예제 #22
0
        public async Task Should_Fail_CreateAsync()
        {
            var serviceProvider = GetServiceProvider();
            InventoryDbContext      dbContext = _dbContext(GetCurrentMethod());
            InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService)))
            .Returns(inventorySummaryService);

            InventoryMovementService service = new InventoryMovementService(serviceProvider.Object, dbContext);
            var data = _dataUtil(service).GetNewData();
            await Assert.ThrowsAnyAsync <Exception>(() => service.Create(null));
        }
        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);
            NewFpRegradingResultDocsService service = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = await _dataUtil(service).GetTestData();

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

            testData.Details.Add(new FpRegradingResultDocsDetails
            {
                Grade       = "a",
                Length      = 12,
                ProductCode = "code",
                ProductId   = "1",
                ProductName = "name",
                Quantity    = 1,
                Remark      = "remar",
                Retur       = "retur"
            });
            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(vm2);

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

            Assert.NotEqual(0, newResponse);
        }
예제 #24
0
        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);
        }
예제 #25
0
        public async Task Should_Success_RefreshMovememnt()
        {
            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()));
            var data = await _dataUtil(inventoryMovementService).GetTestData();

            var result = await inventoryMovementService.RefreshInventoryMovement();

            Assert.NotEqual(0, result);
        }
예제 #26
0
        public async Task Should_Success_ReadById()
        {
            var serviceProvider = GetServiceProvider();
            InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, _dbContext(GetCurrentMethod()));

            serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService)))
            .Returns(inventorySummaryService);

            InventoryMovementService service = new InventoryMovementService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = await _dataUtil(service).GetTestData();

            var model = service.ReadModelById(data.Id);

            Assert.NotNull(model);
        }
예제 #27
0
        public void Should_Success_GenerateExcel_with_EmptyData()
        {
            var serviceProvider = GetServiceProvider();
            InventoryDbContext      dbContext = _dbContext(GetCurrentMethod());
            InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService)))
            .Returns(inventorySummaryService);

            InventoryMovementService service = new InventoryMovementService(serviceProvider.Object, dbContext);

            var Response = service.GenerateExcel(null, null, null, null, null, 7);

            Assert.NotNull(Response);
        }
예제 #28
0
        public async Task Should_Success_CreateAsync()
        {
            var serviceProvider = GetServiceProvider();
            InventoryDbContext      dbContext = _dbContext(GetCurrentMethod());
            InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService)))
            .Returns(inventorySummaryService);

            InventoryMovementService service = new InventoryMovementService(serviceProvider.Object, dbContext);
            var data = _dataUtil(service).GetNewData();

            var Response = await service.Create(data);

            Assert.NotEqual(0, Response);
        }
예제 #29
0
        public void Should_Success_GetReport()
        {
            var serviceProvider = GetServiceProvider();
            InventoryDbContext      dbContext = _dbContext(GetCurrentMethod());
            InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService)))
            .Returns(inventorySummaryService);

            InventoryMovementService service = new InventoryMovementService(serviceProvider.Object, dbContext);
            var data = _dataUtil(service).GetTestData();

            var Response = service.GetReport(null, null, null, null, null, 1, 25, "{}", 7);

            Assert.NotNull(Response);
        }
예제 #30
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);
        }