public void TestMarkComplete()
        {
            ProblemDataManager dataManager = new ProblemDataManager();

            dataManager.AddProblem("Skill1", "Group1", "Problem1", 0, 0, 0);
            dataManager.MarkCompleted("Problem1", true);
            dataManager.MarkCompleted("Problem1", false);
            ProblemsMockDataStorageDelegate storage = new ProblemsMockDataStorageDelegate();

            dataManager.StoreData(storage);

            Assert.AreEqual(1, storage.callCount);
            Assert.AreEqual(2, storage.timesAttempt);
            Assert.AreEqual(1, storage.correct);
        }
Example #2
0
        public void TestRandomize(int problemSetSize, int totalProblems, bool isCorrect)
        {
            string s1  = "s1";
            string g1  = "g1";
            string sgp = s1 + g1 + "-";

            SkillsDataManager sdm = new SkillsDataManager();

            sdm.AddSkill(s1, false);

            ProblemDataManager pdm = new ProblemDataManager();

            for (int i = 0; i < totalProblems; i++)
            {
                pdm.AddProblem(s1, g1, sgp + i.ToString(), 0, 0, 0);
            }

            //Hold the completed problems for later comparison
            IList <string> completedList = new List <string>();

            for (int i = 0; i < totalProblems / problemSetSize; i++)
            {
                DefaultAssessmentBuilder dab = new DefaultAssessmentBuilder(pdm, sdm);
                dab.AddProblem(problemSetSize, g1, "randgrp321");
                Assessment     assess = dab.Build();
                IList <string> probs  = assess.GetProblemSequence();
                foreach (string prob in probs)
                {
                    pdm.MarkCompleted(prob, isCorrect);
                    Assert.IsFalse(completedList.Contains(prob), prob + ": Already in List");
                    completedList.Add(prob);
                }
            }
        }
        public void TestGetProblemsFromGroup()
        {
            ProblemDataManager dataManager = new ProblemDataManager();

            dataManager.AddProblem("Skill1", "Group1", "Problem1", 1, 0, 1);
            dataManager.AddProblem("Skill1", "Group2", "Problem2", 0, 0, 0);
            dataManager.AddProblem("Skill1", "Group1", "Problem3", 1, 0, 2);
            Assert.AreEqual(3, dataManager.GetProblemCount());

            Assert.AreEqual(1, dataManager.GetProblemsFromGroup(1, "Group1").Count);
            Assert.AreEqual(2, dataManager.GetProblemsFromGroup(2, "Group1").Count);

            Assert.AreEqual("Problem1", dataManager.GetProblemsFromGroup(2, "Group1")[0]);
            Assert.AreEqual("Problem3", dataManager.GetProblemsFromGroup(2, "Group1")[1]);

            dataManager.MarkCompleted("Problem1", true);

            Assert.AreEqual(2, dataManager.GetProblemsFromGroup(2, "Group1").Count);
            Assert.AreEqual("Problem3", dataManager.GetProblemsFromGroup(2, "Group1")[0]);
            Assert.AreEqual("Problem1", dataManager.GetProblemsFromGroup(2, "Group1")[1]);
        }