public void GetSubsetMethod() { //setup && seed data var options = new DbContextOptionsBuilder <TestSearchAppContext>() .UseInMemoryDatabase(databaseName: "GetSubsetMethod") .Options; using (TestSearchAppContext context = new TestSearchAppContext(options)) { SearchAppDbInitializer.Initialize(context); SearchController controller = new SearchController(context); //test Assert.IsNotNull(controller.GetSubset("a")); } }
public void GetSubsetMethod_BadInput2() { //setup && seed data var options = new DbContextOptionsBuilder <TestSearchAppContext>() .UseInMemoryDatabase(databaseName: "GetSubsetMethod_BadInput2") .Options; using (TestSearchAppContext context = new TestSearchAppContext(options)) { SearchAppDbInitializer.Initialize(context); SearchController controller = new SearchController(context); List <SearchItem> searchResults = controller.ResultsFromSearch("<asdf;"); //test Assert.IsTrue(searchResults.Count() == 0); } }
public void ResultsFromSearchMethod() { //setup && seed data var options = new DbContextOptionsBuilder <TestSearchAppContext>() .UseInMemoryDatabase(databaseName: "ResultsFromSearchMethod") .Options; using (TestSearchAppContext context = new TestSearchAppContext(options)) { SearchAppDbInitializer.Initialize(context); SearchController controller = new SearchController(context); //test List <SearchItem> results = controller.ResultsFromSearch("a"); //based on searchDB intializer, know what data should have come back Assert.AreEqual(results.Count(), 6); Assert.IsTrue(results.Any(x => x.FirstName == "Carson")); Assert.IsFalse(results.Any(x => x.FirstName == "Peggy")); } }