public async Task GetAsync_ShouldReturnBeerStyleDTOAsync() { //Arrange var options = InMemory.GetOptions("GetAsync_ShouldReturnBeerStyleDTOAsync"); 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)) { //Act var sut = new BeerStylesService(context); var result = await sut.GetAsync(1); //Assert Assert.IsInstanceOfType(result, typeof(BeerStyleDTO));; } }
public async Task GetAsync_ShouldReturnNullIfNoStyleAsync() { //Arrange var options = InMemory.GetOptions("GetAsync_ShouldReturnNullIfNoStyleAsync"); using (var context = new BOContext(options)) { } using (var context = new BOContext(options)) { //Act var sut = new BeerStylesService(context); var result = await sut.GetAsync(1); //Assert Assert.AreEqual(result, null); } }
public async Task GetAsync_ShouldReturnNullIfModelStyleConversionFailsAsync() { //Arrange var options = InMemory.GetOptions("GetAsync_ShouldReturnNullIfModelStyleConversionFailsAsync"); using (var context = new BOContext(options)) { var style = new BeerStyle(); context.BeerStyles.Add(style); await context.SaveChangesAsync(); } using (var context = new BOContext(options)) { //Act var sut = new BeerStylesService(context); var result = await sut.GetAsync(1); //Assert Assert.AreEqual(result, null); } }