public async Task UpdateAsync_ShouldChangeNameOfStyleAndDescriptionAsync() { //Arrange var options = InMemory.GetOptions("UpdateAsync_ShouldChangeNameOfStyleAndDescriptionAsync"); using (var context = new BOContext(options)) { var style = new BeerStyle() { Name = "Ale", Description = "This description" }; context.BeerStyles.Add(style); await context.SaveChangesAsync(); } using (var context = new BOContext(options)) { var styleDTO = new BeerStyleDTO() { Name = "Ale2", Description = "This description2" }; //Act var sut = new BeerStylesService(context); await sut.UpdateAsync(1, styleDTO); var dbresult = await context.BeerStyles.FindAsync(1); //Assert Assert.AreEqual(dbresult.Name, "Ale2"); Assert.AreEqual(dbresult.Description, "This description2"); } }
public async Task UpdateAsync_ShouldReturnNullIfStyleDTONullAsync() { //Arrange var options = InMemory.GetOptions("UpdateAsync_ShouldReturnNullIfStyleDTONullAsync"); using (var context = new BOContext(options)) { } using (var context = new BOContext(options)) { //Act var sut = new BeerStylesService(context); var result = await sut.UpdateAsync(1, null); //Assert Assert.AreEqual(result, null); } }
public async Task UpdateAsync_ShouldReturnNullIfStyleNonExistantAsync() { //Arrange var options = InMemory.GetOptions("UpdateAsync_ShouldReturnNullIfStyleNonExistantAsync"); using (var context = new BOContext(options)) { } using (var context = new BOContext(options)) { var styleDTO = new BeerStyleDTO() { Name = "Ale", Description = "This description" }; //Act var sut = new BeerStylesService(context); var result = await sut.UpdateAsync(1, styleDTO); //Assert Assert.AreEqual(result, null); } }