public async Task ReturnTrue_WhenBarExist() { //Arrange var options = Utils.GetOptions(nameof(ReturnTrue_WhenBarExist)); var record = new Bar() { Name = "BestBar", Rating = 4, TimesRated = 1, ImageSrc = null, IsDeleted = true, Address = "Галичица 17.", Country = "България.", District = "Лозенец.", Email = "*****@*****.**", Phone = "088888888.", Town = "София.", LocationId = null, }; using (var context = new BCcontext(options)) { await context.Bars.AddAsync(record); await context.SaveChangesAsync(); } var mockMapper = new Mock <IBarMapper>(); var http = new Mock <IHttpClientFactory>(); var coctailMapper = new Mock <ICocktailMapper>(); //Act & Assert using (var context = new BCcontext(options)) { var sut = new BarsService(context, mockMapper.Object, http.Object, coctailMapper.Object); var result = await sut.BarExistsByName("BestBar"); Assert.AreEqual(result, true); } }
public async Task ReturnFalse_WhenBarDoesntExist() { //Arrange var options = Utils.GetOptions(nameof(ReturnFalse_WhenBarDoesntExist)); using (var context = new BCcontext(options)) { } var mockMapper = new Mock <IBarMapper>(); var http = new Mock <IHttpClientFactory>(); var coctailMapper = new Mock <ICocktailMapper>(); //Act & Assert using (var context = new BCcontext(options)) { var sut = new BarsService(context, mockMapper.Object, http.Object, coctailMapper.Object); var result = await sut.BarExistsByName("BestBar"); Assert.AreEqual(result, false); } }