Exemplo n.º 1
0
        public async Task Should_Success_AutoJournalVBNonPOClearence_With_ViewModel_When_NotKlaring()
        {
            var dbContext = GetDbContext(GetCurrentMethod());

            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock.Setup(s => s.GetService(typeof(FinanceDbContext))).Returns(dbContext);
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(new JournalHttpClientTestService());
            //IHttpClientService
            Mock <IJournalTransactionService> journalTransactionServiceMock = new Mock <IJournalTransactionService>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IJournalTransactionService)))
            .Returns(journalTransactionServiceMock.Object);

            //  Mock<IMasterCOAService> masterCOAServiceMock = new Mock<IMasterCOAService>();
            var masterCOAServiceMock = new MasterCOAService(serviceProviderMock.Object);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IMasterCOAService)))
            .Returns(masterCOAServiceMock);


            VBRequestDocumentService  vBRequestDocumentService = new VBRequestDocumentService(dbContext, GetServiceProvider().Object);
            VBRequestDocumentNonPODto data = await GetdataUtil(vBRequestDocumentService).GetTestData_VBRequestDocumentNonPO_NotKlaring();

            VBRealizationWithPOService vBRealizationWithPOService = new VBRealizationWithPOService(dbContext, serviceProviderMock.Object);
            var vBRealizationDocumenData = GetDataUtil(vBRealizationWithPOService).GetTestData_DenganNomorVB();

            var service = new AutoJournalService(dbContext, serviceProviderMock.Object);

            AccountBankViewModel viewModel = new AccountBankViewModel()
            {
                AccountCOA    = "AccountCOA",
                AccountName   = "AccountName",
                AccountNumber = "AccountNumber",
                BankCode      = "BankCode",
                BankName      = "BankName",
                Code          = "Code",
                Currency      = new CurrencyViewModel()
                {
                    Code        = "Rp",
                    Description = "Description",
                    Rate        = 1,
                    Symbol      = "IDR"
                }
            };

            List <int> vbRealizationIds = new List <int>()
            {
                1
            };
            var result = await service.AutoJournalVBNonPOClearence(vbRealizationIds, viewModel);

            Assert.NotEqual(0, result);
        }
        public async Task Should_Success_AutoJournalVBNonPOClearence()
        {
            //Setup
            var dbContext           = GetDbContext(GetCurrentMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock.Setup(s => s.GetService(typeof(FinanceDbContext))).Returns(dbContext);
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(new JournalHttpClientTestService());

            Mock <IJournalTransactionService> journalTransactionServiceMock = new Mock <IJournalTransactionService>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IJournalTransactionService)))
            .Returns(journalTransactionServiceMock.Object);

            var masterCOAServiceMock = new MasterCOAService(serviceProviderMock.Object);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IMasterCOAService)))
            .Returns(masterCOAServiceMock);

            var vBRequestDocumentService = new VBRequestDocumentService(dbContext, GetServiceProvider().Object);
            var data = await GetdataUtil(vBRequestDocumentService).GetTestData_VBRequestDocumentNonPO();

            var vBRealizationWithPOService = new VBRealizationWithPOService(dbContext, serviceProviderMock.Object);
            var vBRealizationDocumenData   = GetDataUtil(vBRealizationWithPOService).GetTestData_DenganNomorVB();

            var realization = new Lib.ViewModels.VBRealizationDocumentNonPO.VBRealizationDocumentNonPOViewModel()
            {
                IsInklaring = true,
                Currency    = new Lib.ViewModels.VBRealizationDocumentNonPO.CurrencyViewModel()
                {
                    Code = "USD"
                }
            };

            var vbRealizations = new VBRealizationDocumentModel(realization);

            dbContext.VBRealizationDocuments.Add(vbRealizations);
            dbContext.SaveChanges();

            var service = new AutoJournalService(dbContext, serviceProviderMock.Object);

            List <int> vbRealizationIds = new List <int>()
            {
                1,
                2
            };

            //Act
            var result = await service.AutoJournalVBNonPOClearence(vbRealizationIds);

            //Assert
            Assert.NotEqual(0, result);
        }
Exemplo n.º 3
0
        public async Task Should_Success_AutoJournalVBNonPOClearence_When_NotKlaring()
        {
            //Setup
            var dbContext           = GetDbContext(GetCurrentMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock.Setup(s => s.GetService(typeof(FinanceDbContext))).Returns(dbContext);
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(new JournalHttpClientTestService());

            Mock <IJournalTransactionService> journalTransactionServiceMock = new Mock <IJournalTransactionService>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IJournalTransactionService)))
            .Returns(journalTransactionServiceMock.Object);

            var masterCOAServiceMock = new MasterCOAService(serviceProviderMock.Object);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IMasterCOAService)))
            .Returns(masterCOAServiceMock);

            var vBRequestDocumentService = new VBRequestDocumentService(dbContext, GetServiceProvider().Object);
            var data = await GetdataUtil(vBRequestDocumentService).GetTestData_VBRequestDocumentNonPO_NotKlaring();

            var vBRealizationWithPOService = new VBRealizationWithPOService(dbContext, serviceProviderMock.Object);
            var vBRealizationDocumenData   = GetDataUtil(vBRealizationWithPOService).GetTestData_DenganNomorVB();

            var service = new AutoJournalService(dbContext, serviceProviderMock.Object);

            List <int> vbRealizationIds = new List <int>()
            {
                1
            };

            //Act
            var result = await service.AutoJournalVBNonPOClearence(vbRealizationIds);

            //Assert
            Assert.NotEqual(0, result);
        }
        public async Task Should_Success_AutoJournalVBNonPOClearence_With_ViewModel()
        {
            //Setup
            var dbContext           = GetDbContext(GetCurrentMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock.Setup(s => s.GetService(typeof(FinanceDbContext))).Returns(dbContext);
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(new JournalHttpClientTestService());

            Mock <IJournalTransactionService> journalTransactionServiceMock = new Mock <IJournalTransactionService>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IJournalTransactionService)))
            .Returns(journalTransactionServiceMock.Object);

            var masterCOAServiceMock = new MasterCOAService(serviceProviderMock.Object);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IMasterCOAService)))
            .Returns(masterCOAServiceMock);


            var vBRequestDocumentService = new VBRequestDocumentService(dbContext, GetServiceProvider().Object);
            var data = await GetdataUtil(vBRequestDocumentService).GetTestData_VBRequestDocumentNonPO();

            var vBRealizationWithPOService = new VBRealizationWithPOService(dbContext, serviceProviderMock.Object);
            var vBRealizationDocumenData   = GetDataUtil(vBRealizationWithPOService).GetTestData_DenganNomorVB();

            var expeditionService = new VBRealizationDocumentExpeditionService(dbContext, GetServiceProvider().Object);
            var model             = _dataUtil(expeditionService, dbContext).GetTestData_VBRealizationDocumentExpedition();

            var realization = new Lib.ViewModels.VBRealizationDocumentNonPO.VBRealizationDocumentNonPOViewModel()
            {
                IsInklaring = true,
                Currency    = new Lib.ViewModels.VBRealizationDocumentNonPO.CurrencyViewModel()
                {
                    Code = "IDR"
                }
            };

            var expenditureitem = new Lib.ViewModels.VBRealizationDocumentNonPO.VBRealizationDocumentNonPOExpenditureItemViewModel()
            {
                PPhAmount = 1,
                PPnAmount = 1,
            };

            var unitcostitem = new Lib.ViewModels.VBRealizationDocumentNonPO.VBRealizationDocumentNonPOUnitCostViewModel()
            {
                IsSelected = true
            };

            var vbRealizations          = new VBRealizationDocumentModel(realization);
            var vbRealizationItems      = new VBRealizationDocumentExpenditureItemModel(2, expenditureitem);
            var vbRealizationsUnitItems = new VBRealizationDocumentUnitCostsItemModel(2, unitcostitem);

            dbContext.VBRealizationDocuments.Add(vbRealizations);
            dbContext.VBRealizationDocumentExpenditureItems.Add(vbRealizationItems);
            dbContext.VBRealizationDocumentUnitCostsItems.Add(vbRealizationsUnitItems);
            dbContext.SaveChanges();

            var service = new AutoJournalService(dbContext, serviceProviderMock.Object);

            AccountBankViewModel viewModel = new AccountBankViewModel()
            {
                AccountCOA    = "AccountCOA",
                AccountName   = "AccountName",
                AccountNumber = "AccountNumber",
                BankCode      = "BankCode",
                BankName      = "BankName",
                Code          = "Code",
                Currency      = new CurrencyViewModel()
                {
                    Code        = "Rp",
                    Description = "Description",
                    Rate        = 1,
                    Symbol      = "IDR"
                },
            };

            List <int> vbRealizationIds = new List <int>()
            {
                1,
                2
            };

            //Act
            var result = await service.AutoJournalVBNonPOClearence(vbRealizationIds, viewModel, null);

            //Assert
            Assert.NotEqual(0, result);
        }