public void TestUpdateChallenge()
{
using (_trans)
{
int id;
Log("Creating challenge");
Challenge challenge = new Challenge("Test Challenge", "This is a test challenge",
30, false, DateTime.Today, 1, Statistic.Steps, 500);
Log("Adding challenge to the database");
Assert.IsTrue((id = ChallengeDAO.CreateNewChallenge(challenge)) > 0);
Log("Loading challenge from the database");
Challenge retrieved = ChallengeDAO.GetChallengeFromChallengeId(id);
Log("Verifying that a matching challenge was found");
Assert.IsNotNull(retrieved);
Log("Verifying that the challenge is still active");
Assert.IsTrue(retrieved.IsActive);
retrieved.IsActive = false;
Log("Updating the challenge to be expired");
Assert.IsTrue(ChallengeDAO.UpdateChallenge(retrieved));
Log("Reloading challenge from the database");
Challenge retrieved2 = ChallengeDAO.GetChallengeFromChallengeId(id);
Log("Verifying that a matching challenge was found");
Assert.IsNotNull(retrieved2);
Log("Verifying that the challenge is inactive");
Assert.IsFalse(retrieved2.IsActive);
}
}