public async Task CocktailExistsByName_True_whenExisting() { var options = Utils.GetOptions(nameof(CocktailExistsByName_True_whenExisting)); var mockMapper = new Mock <ICocktailMapper>(); var mockBarMapper = new Mock <IBarMapper>(); var testCocktailName = "TestCocktailName"; var cocktail = new Cocktail() { Name = testCocktailName }; 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 = await sut.CocktailExistsByNameAsync("TestCocktailName"); Assert.IsTrue(result); } }
public async Task CocktailExistsByName_False_whenNotExisting() { var options = Utils.GetOptions(nameof(CocktailExistsByName_False_whenNotExisting)); var mockMapper = new Mock <ICocktailMapper>(); var mockBarMapper = new Mock <IBarMapper>(); //Act and Assert using (var context = new BCcontext(options)) { var sut = new CocktailsService(context, mockMapper.Object, mockBarMapper.Object); var result = await sut.CocktailExistsByNameAsync("TestName"); Assert.IsFalse(result); } }