public async Task GetAllAsync_ShouldReturnIEnumerableBeerStyleDTOAsync() { //Arrange var options = InMemory.GetOptions("GetAllAsync_ShouldReturnIEnumerableBeerStyleDTOAsync"); 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.GetAllAsync(); //Assert Assert.IsInstanceOfType(result, typeof(IEnumerable <BeerStyleDTO>)); } }
public async Task GetAllAsync_ShouldReturnEmptyIfNoStylesAsync() { //Arrange var options = InMemory.GetOptions("GetAllAsync_ShouldReturnEmptyIfNoStylesAsync"); using (var context = new BOContext(options)) { } using (var context = new BOContext(options)) { //Act var sut = new BeerStylesService(context); var result = await sut.GetAllAsync(); //Assert Assert.AreEqual(result.Count(), 0); } }
public async Task GetAllAsync_ShouldReturnNullIfModelStyleHasNoNameFailsAsync() { //Arrange var options = InMemory.GetOptions("GetAllAsync_ShouldReturnNullIfModelStyleHasNoNameFailsAsync"); 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.GetAllAsync(); //Assert Assert.AreEqual(result, null); } }