public void FindByName_ShowInDB_ReturnsShow() { var options = new DbContextOptionsBuilder <EpisodeContext>() .UseInMemoryDatabase(databaseName: "FindByName_ShowInDB_ReturnsShow") .Options; TVShow show1 = new TVShow() { SeriesId = 281662, SeriesName = "Marvel's Daredevil", SeriesNamePreferred = "Daredevil" }; TVShow show2 = new TVShow() { SeriesId = 328487, SeriesName = "The Orville" }; using (var context = new EpisodeContext(options)) { var service = new TVShowService(context); context.Database.EnsureCreated(); service.Add(show1); service.Add(show2); } using (var context = new EpisodeContext(options)) { var service = new TVShowService(context); TVShow result = service.FindByName("marvels daredevil"); Assert.Equal(2, context.Shows.Count()); Assert.Equal("Marvel's Daredevil", result.SeriesName); } }
public void FindByName_ShowNotInDB_ReturnsNull() { var options = new DbContextOptionsBuilder <EpisodeContext>() .UseInMemoryDatabase(databaseName: "FindByName_ShowNotInDB_ReturnsNull") .Options; TVShow show1 = new TVShow() { SeriesId = 281662, SeriesName = "Marvel's Daredevil", SeriesNamePreferred = "Daredevil" }; using (var context = new EpisodeContext(options)) { var service = new TVShowService(context); service.Add(show1); } using (var context = new EpisodeContext(options)) { var service = new TVShowService(context); TVShow result = service.FindByName("Counterpart"); Assert.Null(result); } }