public async Task CocktailExists_True_whenExisting() { var options = Utils.GetOptions(nameof(CocktailExists_True_whenExisting)); var testCocktailId = Utils.MySampleGuid(); var cocktail = new Cocktail() { Id = testCocktailId }; var mockMapper = new Mock <ICocktailMapper>(); var mockBarMapper = new Mock <IBarMapper>(); using (var arrangeContext = new BCcontext(options)) { await arrangeContext.Cocktails.AddAsync(cocktail); await arrangeContext.SaveChangesAsync(); } //Act and Assert using (var context = new BCcontext(options)) { var sut = new CocktailsService(context, mockMapper.Object, mockBarMapper.Object); var result = sut.CocktailExists(testCocktailId); Assert.IsTrue(result); } }
public void CocktailExists_False_whenNotExisting() { var options = Utils.GetOptions(nameof(CocktailExists_False_whenNotExisting)); var testCocktailId = Utils.MySampleGuid(); var mockMapper = new Mock <ICocktailMapper>(); var mockBarMapper = new Mock <IBarMapper>(); using (var arrangeContext = new BCcontext(options)) { } //Act and Assert using (var context = new BCcontext(options)) { var sut = new CocktailsService(context, mockMapper.Object, mockBarMapper.Object); var result = sut.CocktailExists(testCocktailId); Assert.IsFalse(result); } }