public async Task <Domain.Buyer> InsertAsync(BuyerUpdateModel buyer) { var result = await this.Context.AddAsync(this.Mapper.Map <Buyer>(buyer)); await this.Context.SaveChangesAsync(); return(this.Mapper.Map <Domain.Buyer>(result.Entity)); }
public async Task <Domain.Buyer> UpdateAsync(BuyerUpdateModel buyer) { var existing = await this.Get(buyer); var result = this.Mapper.Map(buyer, existing); this.Context.Update(result); await this.Context.SaveChangesAsync(); return(this.Mapper.Map <Domain.Buyer>(result)); }
public async Task CreateAsync_PatientValidationSucceed_CreatesPatient() { // Arrange var patient = new BuyerUpdateModel(); var expected = new Buyer(); var streetService = new Mock <ICityService>(); streetService.Setup(x => x.ValidateAsync(patient)); var patientDAL = new Mock <IBuyerDAL>(); patientDAL.Setup(x => x.InsertAsync(patient)).ReturnsAsync(expected); var patientService = new BuyerService(patientDAL.Object, streetService.Object); // Act var result = await patientService.CreateAsync(patient); // Assert result.Should().Be(expected); }
public async Task CreateAsync_PatientValidationFailed_ThrowsError() { // Arrange var fixture = new Fixture(); var patient = new BuyerUpdateModel(); var expected = fixture.Create <string>(); var streetService = new Mock <ICityService>(); streetService .Setup(x => x.ValidateAsync(patient)) .Throws(new InvalidOperationException(expected)); var patientDAL = new Mock <IBuyerDAL>(); var patientService = new BuyerService(patientDAL.Object, streetService.Object); var action = new Func <Task>(() => patientService.CreateAsync(patient)); // Assert await action.Should().ThrowAsync <InvalidOperationException>().WithMessage(expected); patientDAL.Verify(x => x.InsertAsync(patient), Times.Never); }
public async Task <Buyer> UpdateAsync(BuyerUpdateModel buyer) { await this.CityService.ValidateAsync(buyer); return(await this.BuyerDAL.UpdateAsync(buyer)); }
public Task <Buyer> UpdateAsync(BuyerUpdateModel buyer) { return(BuyerDataAccess.UpdateAsync(buyer)); }
public Task <Buyer> CreateAsync(BuyerUpdateModel buyer) { return(BuyerDataAccess.InsertAsync(buyer)); }