Ejemplo n.º 1
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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 4
0
        public async Task Should_Success_MapToViewModel()
        {
            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.MapToViewModel(data);

            Assert.NotNull(model);
        }