Beispiel #1
0
        public async Task <BankCashReceiptModel> GetTestData_LOKAL()
        {
            BankCashReceiptModel model = GetNewData();
            await Service.CreateAsync(model);

            return(await Service.ReadByIdAsync(model.Id));
        }
Beispiel #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);
        }
        public async Task Should_Success_Delete_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 BankCashReceiptService(serviceProviderMock.Object);

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

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

            var Response = await service.DeleteAsync(newModel.Id);

            //Assert
            Assert.NotEqual(0, Response);
        }
        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 BankCashReceiptService(serviceProviderMock.Object);

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

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

            BankCashReceiptModel newModel2 = new BankCashReceiptModel();

            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 <BankCashReceiptItemModel> {
                model2.Items.First()
            };
            var Response = await service.UpdateAsync(model2.Id, newModel2);

            Assert.NotEqual(0, Response);

            BankCashReceiptItemModel newItem = new BankCashReceiptItemModel
            {
                BankCashReceiptId = 1,
                C1A = 1,
                C1B = 1,
                C2A = 1,
                C2B = 1,
                C2C = 1,
            };

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

            Assert.NotEqual(0, Response);
        }