public void TestUpdateContestChangeName()
{
using (_trans)
{
InitializeTestDBEntries();
int id;
string newName = "New Name";
Log("Creating contest");
Contest contest = new Contest()
{
Name = "Test Contest1",
Description = "This is a test contest",
Mode = ContestEndMode.GoalBased,
Type = ContestType.Group,
StartTime = DateTime.Today,
EndValue = 500,
IsActive = true,
IsSearchable = true,
StatisticBinding = Statistic.Steps,
CreatorId = _user1.UserID
};
Log("Adding contest to the database");
Assert.IsTrue((id = ContestDAO.CreateNewContest(contest)) > 0);
Log("Loading contest from the database");
Contest retrieved = ContestDAO.GetContestFromContestId(id, false, false);
Log("Verifying that a matching contest was found");
Assert.IsNotNull(retrieved);
Log("Renaming the Contest");
retrieved.Name = newName;
Log("Updating the contest in the DB");
Assert.IsTrue(ContestDAO.UpdateContest(retrieved));
Log("Reloading contest from the database");
Contest retrieved2 = ContestDAO.GetContestFromContestId(id, false, false);
Log("Verifying that a matching contest was found");
Assert.IsNotNull(retrieved2);
Log("Verifying that the contest has the new name");
Assert.AreEqual(newName, retrieved2.Name);
}
}