public void TestFindContests()
{
using (_trans)
{
InitializeTestDBEntries();
Log("Creating contests");
//Matches
ContestManager.CreateContest(ContestType.Group, "Testlike",
"This is a test contest", DateTime.Today.AddDays(1), 500, true, Statistic.Steps, _user1.UserID);
//Matches
ContestManager.CreateContest(ContestType.Group, "Testlike Competition",
"This is a test contest", DateTime.Today.AddDays(1), 500, true, Statistic.GasSavings, _user1.UserID);
//Matches
ContestManager.CreateContest(ContestType.Group, "testlikeing again",
"This is a test contest", DateTime.Today.AddDays(1), 500, true, Statistic.GasSavings, _user1.UserID);
//Matches
ContestManager.CreateContest(ContestType.Group, "My Testlike Contest",
"This is a test contest", DateTime.Today, 500, true, Statistic.GasSavings, _user1.UserID);
//Doesn't Match
ContestManager.CreateContest(ContestType.Group, "ActivEarth FTW",
"This is a test contest", DateTime.Today.AddDays(1), 500, true, Statistic.GasSavings, _user1.UserID);
//Matches, but not public
ContestManager.CreateContest(ContestType.Group, "testlike contest2",
"This is a test contest", DateTime.Today.AddDays(1), 500, false, Statistic.GasSavings, _user1.UserID);
//Matches
ContestManager.CreateContest(ContestType.Group, "this is another testlike contest",
"This is a test contest", DateTime.Today.AddDays(1), 500, true, Statistic.GasSavings, _user1.UserID);
Log("Retrieving contest list from DB: Search term: 'testlike', exact match");
List<int> listFromTestExact = ContestDAO.FindContests("testlike", true);
Log("Retrieving contest list from DB: Search term: 'testlike', not exact match");
List<int> listFromTestNotExact = ContestDAO.FindContests("testlike", false);
Log("Retrieving contest list from DB: Search term: 'salamanders', not exact match");
List<int> listFromSalamandersNotExact = ContestDAO.FindContests("salamanders", false);
Log("Retrieving contest list from DB: Search term: 'salamanders', exact match");
List<int> listFromSalamandersExact = ContestDAO.FindContests("salamanders", true);
Log("Verifying returned contest counts");
Assert.AreEqual(1, listFromTestExact.Count);
Assert.AreEqual(5, listFromTestNotExact.Count);
Assert.AreEqual(0, listFromSalamandersNotExact.Count);
Assert.AreEqual(0, listFromSalamandersExact.Count);
}
}