public async Task Should_Success_Update_Model4() { var dbContext = GetDbContext(GetCurrentMethod()); var serviceProviderMock = GetServiceProviderMock(); serviceProviderMock.Setup(serviceProvider => serviceProvider.GetService(typeof(IVBRealizationDocumentExpeditionService))).Returns(new RealizationVbNonPOServiceHelper()); var service = new RealizationVbNonPOService(dbContext, serviceProviderMock.Object); var dataUtil = new RealizationVBNonPODataUtil(service); var viewmodel = dataUtil.GetNewViewModelNew(); viewmodel.Items.Add(new VbNonPORequestDetailViewModel() { DateDetail = DateTimeOffset.Now, Amount = -1000, Remark = "Remark", isGetPPn = false, IncomeTax = new IncomeTaxNew() { Id = 1, name = "name", rate = 1 }, IncomeTaxBy = "income" }); var dataRequestVb = dataUtil.GetDataRequestVB(); dbContext.VbRequests.Add(dataRequestVb); dbContext.SaveChanges(); var result = await service.UpdateAsync(viewmodel.Id, viewmodel); 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); }
public async Task Should_Success_Update_Model() { //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); var service = new RealizationVbNonPOService(dbContext, serviceProviderMock.Object); var dataUtil = new RealizationVBNonPODataUtil(service); //var modelToUpdate = await dataUtil.GetCreatedData(); var viewmodel = dataUtil.GetNewViewModel(); viewmodel.Items.Add(new VbNonPORequestDetailViewModel() { DateDetail = DateTimeOffset.Now, Amount = 123, Remark = "Remark", isGetPPn = true, IncomeTax = new IncomeTaxNew() { Id = 1, name = "name", rate = 1 }, IncomeTaxBy = "income" }); var dataRequestVb = dataUtil.GetNewData_RequestVB(); //Act var result = await service.UpdateAsync(viewmodel.Id, viewmodel); //Assert Assert.NotEqual(0, result); }