public void DatabaseFileOperations() { // Add some content to the existing default database. TestModel.CreateChallenge("challenge-ldb-1", SplitNamesBefore); TestModel.CreateChallenge("challenge-ldb-2", SplitNamesBefore); TestModel.CreateChallenge("challenge-ldb-3", SplitNamesBefore); // Create a new Model instance. ModelXml NewTestModel = new ModelXml(); // Load the existing database file into the new Model. NewTestModel.LoadDatabase(DefaultFilename); // Verify the contents of the database. List <string> challenges = NewTestModel.GetChallenges(); Assert.AreEqual(3, challenges.Count); // TODO: Can we assume the order in the list and/or in the XML file? Assert.AreEqual("challenge-ldb-1", challenges[0]); Assert.AreEqual("challenge-ldb-2", challenges[1]); Assert.AreEqual("challenge-ldb-3", challenges[2]); // TODO: Do I have to check everything here, or can I assume other tests // will provide coverage? }
public void ModifyChallenge_RenameChallenge() { string oldName = "challenge 1"; string newName = "challenge 2"; // ARRANGE List <Split> SplitsAfter = TestModel.CreateChallenge(oldName, SplitNamesBefore); // ACT TestModel.ModifyChallenge(oldName, null, newName); // ASSERT ModelXml VerifyModel = new ModelXml(); VerifyModel.LoadDatabase(DefaultFilename); List <string> challenges = VerifyModel.GetChallenges(); Assert.AreEqual(1, challenges.Count); Assert.AreEqual(newName, challenges[0]); List <Split> SplitsAfterAfter = VerifyModel.GetSplits(newName); // Verify split names. Assert.AreEqual(SplitsAfter.Count, SplitsAfterAfter.Count); Assert.AreEqual(SplitsAfter[0].Name, SplitsAfterAfter[0].Name); Assert.AreEqual(SplitsAfter[1].Name, SplitsAfterAfter[1].Name); Assert.AreEqual(SplitsAfter[2].Name, SplitsAfterAfter[2].Name); Assert.AreEqual(SplitsAfter[3].Name, SplitsAfterAfter[3].Name); // Verify that Handle didn't change. Assert.AreEqual(SplitsAfter[0].Handle, SplitsAfterAfter[0].Handle); Assert.AreEqual(SplitsAfter[1].Handle, SplitsAfterAfter[1].Handle); Assert.AreEqual(SplitsAfter[2].Handle, SplitsAfterAfter[2].Handle); Assert.AreEqual(SplitsAfter[3].Handle, SplitsAfterAfter[3].Handle); }
public void CreateDatabase_SecondOne() { // We already have the default database loaded; now try // to load a different one to replace it. But first, // add a challenge to the default so that there is a // difference between the two. TestModel.CreateChallenge("challenge1", SplitNamesBefore); string filename = "homtest.xml"; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } // Main thing is to check for exceptions thrown during creation. TestModel.CreateDatabase(filename); List <string> challenges = TestModel.GetChallenges(); Assert.AreEqual(0, challenges.Count); }