Example #1
0
        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);
        }
Example #2
0
        public void ModifyChallenge_SwapTwoSplits()
        {
            // ARRANGE

            // Create a new challenge.
            string challengeName = "new challenge";

            TestModel.CreateChallenge(challengeName, SplitNamesBefore);

            // Get the splits.
            List <Split> SplitsAfter = TestModel.GetSplits(challengeName);

            // ACT
            List <Split> newSplitOrder = new List <Split>();

            newSplitOrder.Add(new Split {
                Handle = SplitsAfter[0].Handle, Name = SplitsAfter[0].Name
            });
            newSplitOrder.Add(new Split {
                Handle = SplitsAfter[1].Handle, Name = SplitsAfter[1].Name
            });
            newSplitOrder.Add(new Split {
                Handle = SplitsAfter[3].Handle, Name = SplitsAfter[3].Name
            });
            newSplitOrder.Add(new Split {
                Handle = SplitsAfter[2].Handle, Name = SplitsAfter[2].Name
            });

            TestModel.ModifyChallenge(challengeName, newSplitOrder, null);

            // ASSERT
            ModelXml VerifyModel = new ModelXml();

            VerifyModel.LoadDatabase(DefaultFilename);

            List <Split> SplitsAfterAfter = VerifyModel.GetSplits(challengeName);

            // Verify split names.
            Assert.AreEqual(newSplitOrder.Count, SplitsAfterAfter.Count);
            Assert.AreEqual(newSplitOrder[0].Name, SplitsAfterAfter[0].Name);
            Assert.AreEqual(newSplitOrder[1].Name, SplitsAfterAfter[1].Name);
            Assert.AreEqual(newSplitOrder[2].Name, SplitsAfterAfter[2].Name);
            Assert.AreEqual(newSplitOrder[3].Name, SplitsAfterAfter[3].Name);

            // Verify that Handle didn't change.
            Assert.AreEqual(newSplitOrder[0].Handle, SplitsAfterAfter[0].Handle);
            Assert.AreEqual(newSplitOrder[1].Handle, SplitsAfterAfter[1].Handle);
            Assert.AreEqual(newSplitOrder[2].Handle, SplitsAfterAfter[2].Handle);
            Assert.AreEqual(newSplitOrder[3].Handle, SplitsAfterAfter[3].Handle);
        }
Example #3
0
        public void ModifyChallenge_RenameAllSplits()
        {
            // ARRANGE

            // Create a new challenge.
            string challengeName = "new challenge";

            TestModel.CreateChallenge(challengeName, SplitNamesBefore);

            // Get the splits.
            List <Split> SplitsAfter = TestModel.GetSplits(challengeName);

            // ACT
            string newSplitName = "this is a new name";

            foreach (var split in SplitsAfter)
            {
                split.Name = newSplitName;
            }
            TestModel.ModifyChallenge(challengeName, SplitsAfter, null);

            // ASSERT
            ModelXml VerifyModel = new ModelXml();

            VerifyModel.LoadDatabase(DefaultFilename);

            List <Split> SplitsAfterAfter = VerifyModel.GetSplits(challengeName);

            // Verify split names.
            Assert.AreEqual(SplitsAfter.Count, SplitsAfterAfter.Count);
            Assert.AreEqual(newSplitName, SplitsAfterAfter[0].Name);
            Assert.AreEqual(newSplitName, SplitsAfterAfter[1].Name);
            Assert.AreEqual(newSplitName, SplitsAfterAfter[2].Name);
            Assert.AreEqual(newSplitName, 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);
        }
Example #4
0
        public void GetSplits_Basic()
        {
            // Create a new challenge.
            TestModel.CreateChallenge("new challenge", SplitNamesBefore);

            // Get the splits.
            List <Split> SplitsAfter = TestModel.GetSplits("new challenge");

            // Verify split names.
            Assert.AreEqual(4, SplitsAfter.Count);
            Assert.AreEqual("one", SplitsAfter[0].Name);
            Assert.AreEqual("two", SplitsAfter[1].Name);
            Assert.AreEqual("three", SplitsAfter[2].Name);
            Assert.AreEqual("four", SplitsAfter[3].Name);

            // We don't know the implementation details, except that
            // Handle must be unique between different Splits.
            Assert.AreNotEqual(SplitsAfter[0].Handle, SplitsAfter[1].Handle);
            Assert.AreNotEqual(SplitsAfter[0].Handle, SplitsAfter[2].Handle);
            Assert.AreNotEqual(SplitsAfter[0].Handle, SplitsAfter[3].Handle);
            Assert.AreNotEqual(SplitsAfter[1].Handle, SplitsAfter[2].Handle);
            Assert.AreNotEqual(SplitsAfter[1].Handle, SplitsAfter[3].Handle);
            Assert.AreNotEqual(SplitsAfter[2].Handle, SplitsAfter[3].Handle);
        }