public async Task <RealizationVbNonPOViewModel> GetTestData() { var model = GetNewData(); var viewmodel = GetNewViewModel(); await Service.CreateAsync(model, viewmodel); return(await Service.ReadByIdAsync2(model.Id)); }
public async Task Should_Success_Create_Model_New_6() { //Arrange var dbContext = GetDbContext(GetCurrentMethod()); var serviceProviderMock = GetServiceProviderMock(); var IVBRealizationDocumentExpeditionServiceMock = new Mock <IVBRealizationDocumentExpeditionService>(); IVBRealizationDocumentExpeditionServiceMock .Setup(s => s.InitializeExpedition(It.IsAny <int>())) .ReturnsAsync(1); serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IVBRealizationDocumentExpeditionService))).Returns(IVBRealizationDocumentExpeditionServiceMock.Object); serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService))).Returns(new HttpClientOthersExpenditureServiceHelper()); var service = new RealizationVbNonPOService(dbContext, serviceProviderMock.Object); var dataUtil = new RealizationVBNonPODataUtil(service); var model = dataUtil.GetNewData(); var dataRequestVb = dataUtil.GetNewData_RequestVB(); dbContext.VbRequests.Add(dataRequestVb); dbContext.SaveChanges(); var viewmodel = dataUtil.GetNewViewModel6(); //Act var result = await service.CreateAsync(model, viewmodel); //Assert Assert.NotEqual(0, result); }
public async Task Should_Success_UpdateAsync_When_Data_Exist() { //Arrange var dbContext = GetDbContext(GetCurrentMethod()); var serviceProviderMock = GetServiceProviderMock(); var IVBRealizationDocumentExpeditionServiceMock = new Mock <IVBRealizationDocumentExpeditionService>(); IVBRealizationDocumentExpeditionServiceMock .Setup(s => s.UpdateExpeditionByRealizationId(It.IsAny <int>())) .ReturnsAsync(1); serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IVBRealizationDocumentExpeditionService))).Returns(IVBRealizationDocumentExpeditionServiceMock.Object); serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IHttpClientService))).Returns(new HttpClientOthersExpenditureServiceHelper()); var service = new RealizationVbNonPOService(dbContext, serviceProviderMock.Object); var dataUtil = new RealizationVBNonPODataUtil(service); var modelToCreate = dataUtil.GetNewData(); var dataRequestVb = dataUtil.GetNewData_RequestVB(); dbContext.VbRequests.Add(dataRequestVb); dbContext.SaveChanges(); var viewmodel = dataUtil.GetNewViewModel5(); var viewmodelnew = dataUtil.GetNewViewModelNew1(); viewmodelnew.Items.Add(new VbNonPORequestDetailViewModel() { DateDetail = DateTimeOffset.Now, Amount = 1000, Remark = "Remark", isGetPPn = false, isGetPPh = true, IncomeTax = new IncomeTaxNew() { Id = 1, name = "name", rate = 1 }, IncomeTaxBy = "income" }); var viewmodel1 = dataUtil.GetNewViewModel6(); await service.CreateAsync(modelToCreate, viewmodel); await service.MappingData(viewmodel1); //Act var result = await service.UpdateAsync(modelToCreate.Id, viewmodelnew); //Assert Assert.NotEqual(0, result); }