Esempio n. 1
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_ValidateNullVM()
        {
            serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryRepository)))
            .Returns(summaryRepository);
            serviceProvider.Setup(s => s.GetService(typeof(IInventoryMovementRepository)))
            .Returns(movementRepository);

            var vm = new InventoryDocumentViewModel()
            {
                Items = new List <InventoryDocumentItemViewModel>()
            };
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);
            var response = vm.Validate(validationContext);

            Assert.True(response.Count() > 0);
        }
        public void Should_Success_Validate_When_Type_ADJ()
        {
            var serviceProvider          = GetServiceProvider();
            InventoryDbContext dbContext = _dbContext(GetCurrentMethod());

            InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, dbContext);

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

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

            serviceProvider
            .Setup(s => s.GetService(typeof(IInventoryMovementService)))
            .Returns(inventoryMovementService);


            InventoryDocumentService service = new InventoryDocumentService(serviceProvider.Object, dbContext);
            var vm = new InventoryDocumentViewModel()
            {
                no    = "1",
                code  = "code",
                items = new List <InventoryDocumentItemViewModel>()
                {
                    new InventoryDocumentItemViewModel()
                    {
                        quantity = 0
                    }
                }
                ,
                type = "ADJ"
            };
            ValidationContext validationContext = new ValidationContext(vm, serviceProvider.Object, null);
            var response = vm.Validate(validationContext);

            Assert.True(response.Count() > 0);
        }