Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
 public async Task Should_Fail_UpdateAsync()
 {
     var serviceProvider = GetServiceProvider();
     NewFpRegradingResultDocsService   serviceMrn = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
     NewFPReturnInvToPurchasingService service    = new NewFPReturnInvToPurchasingService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
     await Assert.ThrowsAnyAsync <Exception>(() => service.UpdateAsync(99, new Lib.Models.FPReturnInvToPurchasingModel.FPReturnInvToPurchasing()));
 }
Exemple #4
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);
        }
Exemple #5
0
 public async Task Should_Fail_CreateAsync()
 {
     var serviceProvider = GetServiceProvider();
     NewFpRegradingResultDocsService   serviceMrn = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
     NewFPReturnInvToPurchasingService service    = new NewFPReturnInvToPurchasingService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
     var data = _dataUtil(service, serviceMrn).GetNewData();
     await Assert.ThrowsAnyAsync <Exception>(() => service.CreateAsync(data));
 }
Exemple #6
0
        public void Should_Success_MapToModel()
        {
            var serviceProvider = GetServiceProvider();
            NewFpRegradingResultDocsService   serviceMrn = new NewFpRegradingResultDocsService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            NewFPReturnInvToPurchasingService service    = new NewFPReturnInvToPurchasingService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = _dataUtil(service, serviceMrn).GetEmptyData();


            var model = service.MapToModel(data);

            Assert.NotNull(model);
        }
Exemple #7
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);
        }
Exemple #8
0
 private FPReturnInvToPurchasingDataUtil _dataUtil(NewFPReturnInvToPurchasingService service, NewFpRegradingResultDocsService fprrService)
 {
     GetServiceProvider();
     return(new FPReturnInvToPurchasingDataUtil(service, fprrService));
 }
Exemple #9
0
 public FPReturnInvToPurchasingDataUtil(NewFPReturnInvToPurchasingService service, NewFpRegradingResultDocsService fprService)
 {
     Service    = service;
     FPRService = fprService;
 }