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

            Assert.True(response.Count() > 0);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        public void Should_Success_MapToModel()
        {
            NewStockTransferNoteService service = new NewStockTransferNoteService(GetFailServiceProvider().Object, _dbContext(GetCurrentMethod()));
            var data = _dataUtil(service).GetNewData();
            var vm   = service.MapToViewModel(data);

            var model = service.MapToModel(vm);

            Assert.NotNull(model);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public async Task Should_Fail_UpdateIsApproved()
        {
            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();

            await Assert.ThrowsAnyAsync <Exception>(() => service.UpdateIsApprove(99));
        }
Esempio n. 7
0
        public async Task Should_Success_CreateAsync()
        {
            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 = _dataUtil(service).GetNewData();

            var Response = await service.CreateAsync(data);

            Assert.NotEqual(0, Response);
        }
Esempio n. 8
0
        public async Task Should_Success_UpdateIsApproved()
        {
            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 response = await service.UpdateIsApprove(data.Id);

            Assert.True(response);
        }
Esempio n. 9
0
        public async Task Should_Success_ReadModelByNotUser()
        {
            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 model = service.ReadModelByNotUser(1, 25, "{}", null, null, "{}");

            Assert.NotNull(model);
        }
Esempio n. 10
0
 private StockTransferNoteDataUtil _dataUtil(NewStockTransferNoteService service)
 {
     GetServiceProvider();
     return(new StockTransferNoteDataUtil(service));
 }
Esempio n. 11
0
 public async Task Should_Fail_UpdateAsync()
 {
     NewStockTransferNoteService service = new NewStockTransferNoteService(GetFailServiceProvider().Object, _dbContext(GetCurrentMethod()));
     await Assert.ThrowsAnyAsync <Exception>(() => service.UpdateAsync(99, new Lib.Models.StockTransferNoteModel.StockTransferNote()));
 }
Esempio n. 12
0
        public async Task Should_Fail_DeleteAsync()
        {
            NewStockTransferNoteService service = new NewStockTransferNoteService(GetFailServiceProvider().Object, _dbContext(GetCurrentMethod()));

            await Assert.ThrowsAnyAsync <Exception>(() => service.DeleteAsync(0));
        }
Esempio n. 13
0
 public async Task Should_Fail_CreateAsync()
 {
     NewStockTransferNoteService service = new NewStockTransferNoteService(GetFailServiceProvider().Object, _dbContext(GetCurrentMethod()));
     var data = _dataUtil(service).GetNewData();
     await Assert.ThrowsAnyAsync <Exception>(() => service.CreateAsync(data));
 }
Esempio n. 14
0
 public StockTransferNoteDataUtil(NewStockTransferNoteService service)
 {
     Service = service;
 }