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 <BankCashReceiptDetailModel> GetTestData() { BankCashReceiptDetailModel model = GetNewData(); await Service.CreateAsync(model); return(await Service.ReadByIdAsync(model.Id)); }