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);
        }
示例#2
0
        public void Should_Success_ValidateNullDetailVM()
        {
            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);

            serviceProvider.Setup(x => x.GetService(typeof(IMaterialRequestNoteRepository)))
            .Returns(repositoryMrn);

            MaterialDistributionNoteRepository repository = new MaterialDistributionNoteRepository(serviceProvider.Object, inventoryDbContext);
            var vm = new MaterialDistributionNoteViewModel()
            {
                MaterialDistributionNoteItems = new List <MaterialDistributionNoteItemViewModel>()
                {
                    new MaterialDistributionNoteItemViewModel()
                }
            };
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);

            var response = vm.Validate(InventorySummaryRepository.GetByStorageAndMTR);

            Assert.True(response.Count() > 0);
        }
示例#3
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);
        }