Пример #1
0
        public async Task Should_Success_GetLoader()
        {
            var dbContext = GetDbContext(GetCurrentMethod());

            var serviceProviderMock = new Mock <IServiceProvider>();

            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IAutoJournalService))).Returns(new AutoJournalServiceTestHelper());
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IAutoDailyBankTransactionService))).Returns(new AutoDailyBankTransactionServiceHelper());
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService))).Returns(new HttpClientOthersExpenditureServiceHelper());
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IIdentityService))).Returns(new IdentityService()
            {
                Username = "******", Token = "token", TimezoneOffset = 1
            });
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService))).Returns(new HttpClientOthersExpenditureServiceHelper());

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

            var model = GetCreateDataUtil();
            await service.CreateAsync(model);

            var createdModel = dbContext.OthersExpenditureProofDocuments.FirstOrDefault();
            var response     = await service.GetLoaderAsync(createdModel.DocumentNo, "{}");

            Assert.NotEqual(0, response.Data.Count);
        }
Пример #2
0
        public async Task Should_Success_Update_Data()
        {
            var dbContext = GetDbContext(GetCurrentMethod());

            var serviceProviderMock = new Mock <IServiceProvider>();

            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IAutoJournalService))).Returns(new AutoJournalServiceTestHelper());
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IAutoDailyBankTransactionService))).Returns(new AutoDailyBankTransactionServiceHelper());
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IIdentityService))).Returns(new IdentityService()
            {
                Username = "******", Token = "token", TimezoneOffset = 1
            });
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService))).Returns(new HttpClientOthersExpenditureServiceHelper());

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

            var model = GetCreateDataUtil();

            model.Items.Add(new OthersExpenditureProofDocumentCreateUpdateItemViewModel()
            {
                COAId  = 3,
                Debit  = 3,
                Remark = "Remark"
            });
            await service.CreateAsync(model);

            var createdModel = dbContext.OthersExpenditureProofDocuments.FirstOrDefault();

            var modelToUpdate = new OthersExpenditureProofDocumentCreateUpdateViewModel()
            {
                AccountBankCode = model.AccountBankCode,
                AccountBankId   = createdModel.AccountBankId,
                Date            = createdModel.Date,
                Items           = new List <OthersExpenditureProofDocumentCreateUpdateItemViewModel>()
                {
                    new OthersExpenditureProofDocumentCreateUpdateItemViewModel()
                    {
                        COAId  = 10,
                        Debit  = 6,
                        Id     = dbContext.OthersExpenditureProofDocumentItems.FirstOrDefault(item => item.OthersExpenditureProofDocumentId == createdModel.Id).Id,
                        Remark = "New remark"
                    },
                    new OthersExpenditureProofDocumentCreateUpdateItemViewModel()
                    {
                        COAId  = 5,
                        Debit  = 2,
                        Remark = "New remark"
                    }
                },
                CekBgNo = createdModel.CekBgNo,
                Remark  = createdModel.Remark,
                Type    = createdModel.Type
            };

            var response = await service.UpdateAsync(createdModel.Id, modelToUpdate);

            Assert.NotNull(response);
        }
Пример #3
0
        public async Task Should_Success_Create_Data()
        {
            var dbContext = GetDbContext(GetCurrentMethod());

            var serviceProviderMock = new Mock <IServiceProvider>();

            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IAutoJournalService))).Returns(new AutoJournalServiceTestHelper());
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IIdentityService))).Returns(new IdentityService()
            {
                Username = "******", Token = "token", TimezoneOffset = 1
            });

            var service = new OthersExpenditureProofDocumentService(dbContext, serviceProviderMock.Object);
            var model   = GetCreateDataUtil();

            var response = await service.CreateAsync(model);

            Assert.NotEqual(0, response);
        }
Пример #4
0
        public async Task Should_Success_Get_Single_Data_By_Id()
        {
            var dbContext = GetDbContext(GetCurrentMethod());

            var serviceProviderMock = new Mock <IServiceProvider>();

            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IAutoJournalService))).Returns(new AutoJournalServiceTestHelper());
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IIdentityService))).Returns(new IdentityService()
            {
                Username = "******", Token = "token", TimezoneOffset = 1
            });

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

            var model = GetCreateDataUtil();
            await service.CreateAsync(model);

            var createdModel = dbContext.OthersExpenditureProofDocuments.FirstOrDefault();
            var response     = await service.GetSingleByIdAsync(createdModel.Id);

            Assert.NotNull(response);
        }
Пример #5
0
        public async Task Should_Success_Posting_Data()
        {
            var dbContext = GetDbContext(GetCurrentMethod());

            var serviceProviderMock = new Mock <IServiceProvider>();

            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IAutoJournalService))).Returns(new AutoJournalServiceTestHelper());
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IAutoDailyBankTransactionService))).Returns(new AutoDailyBankTransactionServiceHelper());
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IIdentityService))).Returns(new IdentityService()
            {
                Username = "******", Token = "token", TimezoneOffset = 1
            });
            serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService))).Returns(new HttpClientOthersExpenditureServiceHelper());

            var service = new OthersExpenditureProofDocumentService(dbContext, serviceProviderMock.Object);
            var model   = GetCreateDataUtil();

            await service.CreateAsync(model);

            var response = await service.Posting(dbContext.OthersExpenditureProofDocuments.Select(entity => entity.Id).ToList());

            Assert.NotEqual(0, response);
        }