Ejemplo n.º 1
0
        public async Task Should_Success_Get_Data_By_Id()
        {
            //Arrange
            var dbContext           = GetDbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            var httpClientService = new Mock <IHttpClientService>();

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(FinanceDbContext)))
            .Returns(dbContext);

            var service = new BankCashReceiptDetailService(serviceProviderMock.Object);

            var dto = await _dataUtil(service, GetCurrentAsyncMethod()).GetTestData();

            //Act
            var Response = service.ReadByIdAsync(dto.Id);

            //Assert
            Assert.NotNull(Response);
        }
Ejemplo n.º 2
0
        public async Task Should_Success_Create_Data()
        {
            //Arrange
            var dbContext           = GetDbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            var httpClientService = new Mock <IHttpClientService>();

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(FinanceDbContext)))
            .Returns(dbContext);

            var service        = new BankCashReceiptDetailService(serviceProviderMock.Object);
            var serviceReceipt = new BankCashReceiptService(serviceProviderMock.Object);

            var dto = _dataUtilReceipt(serviceReceipt, GetCurrentAsyncMethod()).GetTestData();
            //Act
            var ResponseReceipt = serviceReceipt.ReadByIdAsync(dto.Id);

            Assert.NotNull(ResponseReceipt);

            var model = _dataUtil(service, GetCurrentAsyncMethod()).GetNewData();

            //Act
            var Response = await service.CreateAsync(model);

            //Assert
            Assert.NotEqual(0, Response);
        }
Ejemplo n.º 3
0
        public async Task Should_Success_GetAmount()
        {
            var dbContext           = GetDbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            var httpClientService = new Mock <IHttpClientService>();

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(FinanceDbContext)))
            .Returns(dbContext);

            var service = new BankCashReceiptDetailService(serviceProviderMock.Object);

            var dto = await _dataUtil(service, GetCurrentAsyncMethod()).GetTestData();

            //Act
            var Response = service.GetAmountByInvoiceId(dto.Items.First().InvoiceId);

            //Assert
            Assert.NotEqual(Response, 0);
        }
        public async Task Should_Success_Get_All_Data()
        {
            var dbContext           = GetDbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            var httpClientService = new Mock <IHttpClientService>();

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(FinanceDbContext)))
            .Returns(dbContext);

            var service = new BankCashReceiptDetailService(serviceProviderMock.Object);

            var dto = await _dataUtil(service, GetCurrentAsyncMethod()).GetTestData();

            GarmentFinanceBankCashReceiptMonthlyRecapService serviceReport = new GarmentFinanceBankCashReceiptMonthlyRecapService(serviceProviderMock.Object, dbContext);


            var response = serviceReport.GetMonitoring(DateTimeOffset.Now.AddDays(-3), DateTimeOffset.Now.AddDays(3), 7);

            Assert.NotNull(response);
        }
Ejemplo n.º 5
0
        public async Task Should_Success_Get_All_Data()
        {
            var serviceProviderMock = GetServiceProvider();

            var dbContext = GetDbContext(GetCurrentAsyncMethod());

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(FinanceDbContext)))
            .Returns(dbContext);

            var serviceProvider1 = new Mock <IServiceProvider>();

            var httpClientService = new Mock <IHttpClientService>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IIdentityService)))
            .Returns(new IdentityService()
            {
                Token = "Token", Username = "******", TimezoneOffset = 7
            });

            HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.OK);

            message.Content = new StringContent("{\"apiVersion\":\"1.0\",\"statusCode\":200,\"message\":\"Ok\",\"data\":[{\"rate\":\"14500\",\"invoiceNo\":\"no\",\"amount\":1,\"balanceAmount\":1,\"date\":\"2018/10/20\",\"truckingDate\":\"2018/10/20\"}],\"info\":{\"count\":1,\"page\":1,\"size\":1,\"total\":2,\"order\":{\"date\":\"desc\"},\"select\":[\"Id\",\"CustomsType\",\"BeacukaiDate\",\"BeacukaiNo\",,\"POSerialNumber\"]}}");

            HttpResponseMessage messageC = new HttpResponseMessage(System.Net.HttpStatusCode.OK);

            messageC.Content = new StringContent("{\"apiVersion\":\"1.0\",\"statusCode\":200,\"message\":\"Ok\",\"data\":{\"Rate\":14500.0,\"Uid\":\"no\",\"Date\":\"2018-10-20T17:00:00\",\"Code\":\"USD\"},\"info\":{\"count\":1,\"page\":1,\"size\":1,\"total\":1,\"order\":{\"Date\":\"desc\"},\"select\":[\"Rate\"]}}");

            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("garment-shipping/invoices/exportSalesDebtor"))))
            .ReturnsAsync(message);
            serviceProvider1
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(new HttpClientTestService());


            serviceProvider1
            .Setup(x => x.GetService(typeof(IIdentityService)))
            .Returns(new IdentityService()
            {
                Token = "Token", Username = "******", TimezoneOffset = 7
            });

            serviceProvider1
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            GarmentFinanceMemorialDetailService serviceMemo = new GarmentFinanceMemorialDetailService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            GarmentFinanceMemorialDetailModel   modelMemo   = await _dataUtilMemo(serviceMemo, GetCurrentMethod()).GetTestData();

            BankCashReceiptDetailService serviceBankCash        = new BankCashReceiptDetailService(serviceProviderMock.Object);
            BankCashReceiptDetailModel   cashReceiptDetailModel = await _dataUtilBankCash(serviceBankCash).GetTestData();

            GarmentFinanceExportSalesOutstandingReportService service = new GarmentFinanceExportSalesOutstandingReportService(serviceProvider1.Object, _dbContext(GetCurrentMethod()));

            var response = service.GetMonitoring(DateTimeOffset.Now.Month, DateTimeOffset.Now.Year, null, 7);

            Assert.NotNull(response);
        }
Ejemplo n.º 6
0
        private BankCashReceiptDetailDataUtil _dataUtil(BankCashReceiptDetailService service, string testname)
        {
            var dbContext           = GetDbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(FinanceDbContext)))
            .Returns(dbContext);

            var bankCashReceiptService  = new BankCashReceiptService(serviceProviderMock.Object);
            var bankCashReceiptDataUtil = new BankCashReceiptDataUtil(bankCashReceiptService);

            return(new BankCashReceiptDetailDataUtil(service, bankCashReceiptDataUtil));
        }
Ejemplo n.º 7
0
        public async Task Should_Success_Update_Data()
        {
            //Arrange
            var dbContext           = GetDbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            var httpClientService = new Mock <IHttpClientService>();

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(FinanceDbContext)))
            .Returns(dbContext);

            var service = new BankCashReceiptDetailService(serviceProviderMock.Object);

            var model = await _dataUtil(service, GetCurrentAsyncMethod()).GetTestData();

            var model2 = await _dataUtil(service, GetCurrentAsyncMethod()).GetTestData();

            BankCashReceiptDetailModel newModel2 = new BankCashReceiptDetailModel();

            newModel2.Id = model2.Id;
            //Act
            var newModel = await service.ReadByIdAsync(model.Id);

            var Response1 = await service.UpdateAsync(newModel.Id, newModel);

            Assert.NotEqual(0, Response1);

            newModel2.Items = new List <BankCashReceiptDetailItemModel> {
                model2.Items.First()
            };
            newModel2.OtherItems = new List <BankCashReceiptDetailOtherItemModel> {
                model2.OtherItems.First()
            };
            var Response = await service.UpdateAsync(model2.Id, newModel2);

            Assert.NotEqual(0, Response);

            BankCashReceiptDetailItemModel newItem = new BankCashReceiptDetailItemModel
            {
                BankCashReceiptDetailId = 1,
                Amount = 2,
            };

            BankCashReceiptDetailOtherItemModel newOtherItem = new BankCashReceiptDetailOtherItemModel
            {
                BankCashReceiptDetailId = 1,
                Amount     = 2,
                TypeAmount = "KREDIT"
            };

            newModel2.Items.Add(newItem);
            newModel2.OtherItems.Add(newOtherItem);
            var Response3 = await service.UpdateAsync(model2.Id, newModel2);

            Assert.NotEqual(0, Response);

            // delete item and other item
            BankCashReceiptDetailModel newModel3 = new BankCashReceiptDetailModel();

            newModel3.Id = model2.Id;

            newModel3.Items      = new List <BankCashReceiptDetailItemModel>();
            newModel3.OtherItems = new List <BankCashReceiptDetailOtherItemModel>();
            var Response4 = await service.UpdateAsync(model2.Id, newModel3);

            Assert.NotEqual(0, Response4);
        }
 public BankCashReceiptDetailDataUtil(BankCashReceiptDetailService service, BankCashReceiptDataUtil bankCashReceiptDataUtil)
 {
     Service = service;
     BankCashReceiptDataUtil = bankCashReceiptDataUtil;
 }
        public async Task Should_Success_Get_All_DataExcel()
        {
            var serviceProviderMock = GetServiceProvider();

            var dbContext = GetDbContext(GetCurrentAsyncMethod());

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(FinanceDbContext)))
            .Returns(dbContext);

            var serviceProvider1 = new Mock <IServiceProvider>();

            var httpClientService = new Mock <IHttpClientService>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IIdentityService)))
            .Returns(new IdentityService()
            {
                Token = "Token", Username = "******", TimezoneOffset = 7
            });

            HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.OK);

            message.Content = new StringContent("{\"apiVersion\":\"1.0\",\"statusCode\":200,\"message\":\"Ok\",\"data\":[{\"id\":\"145\",\"noteNo\":\"no\",\"date\":\"2018/10/20\",\"buyer\":{\"name\":\"tes\"},\"items\":[{\"price\":1000,\"quantity\":20}]}],\"info\":{\"count\":1,\"page\":1,\"size\":1,\"total\":2,\"order\":{\"date\":\"desc\"},\"select\":[\"Id\",\"CustomsType\",\"BeacukaiDate\",\"BeacukaiNo\",,\"POSerialNumber\"]}}");

            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("garment-shipping/local-sales-notes/localSalesDebtorNow"))))
            .ReturnsAsync(message);
            serviceProvider1
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(new HttpClientTestService());


            serviceProvider1
            .Setup(x => x.GetService(typeof(IIdentityService)))
            .Returns(new IdentityService()
            {
                Token = "Token", Username = "******", TimezoneOffset = 7
            });

            serviceProvider1
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            GarmentFinanceMemorialDetailService serviceMemo = new GarmentFinanceMemorialDetailService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            GarmentFinanceMemorialDetailModel   modelMemo   = await _dataUtilMemo(serviceMemo, GetCurrentMethod()).GetTestData();

            BankCashReceiptDetailService serviceBankCash        = new BankCashReceiptDetailService(serviceProviderMock.Object);
            BankCashReceiptDetailModel   cashReceiptDetailModel = await _dataUtilBankCash(serviceBankCash).GetTestData();

            GarmentFinanceLocalSalesOutstandingReportService service = new GarmentFinanceLocalSalesOutstandingReportService(serviceProvider1.Object, _dbContext(GetCurrentMethod()));

            var response = service.GenerateExcel(DateTimeOffset.Now.Month, DateTimeOffset.Now.Year, "code", 7);

            Assert.NotNull(response);
            var response1 = service.GenerateExcel(1, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response2 = service.GenerateExcel(2, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response3 = service.GenerateExcel(3, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response4 = service.GenerateExcel(4, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response5 = service.GenerateExcel(5, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response6 = service.GenerateExcel(6, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response7 = service.GenerateExcel(7, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response8 = service.GenerateExcel(8, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response9 = service.GenerateExcel(9, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response10 = service.GenerateExcel(10, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response11 = service.GenerateExcel(11, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
            var response12 = service.GenerateExcel(12, DateTimeOffset.Now.Year, "", 7);

            Assert.NotNull(response);
        }