public void ResetLearningProgressTest() { if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary dictionary = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) { ICardsTests.FillDummyDic(dictionary); dictionary.HighScore = 50; dictionary.ResetLearningProgress(); Assert.AreEqual(dictionary is XmlDictionary ? 0 : 10, dictionary.UserSettings.SelectedLearnChapters.Count, "SelectedLearnChapters were not resetted."); foreach (ICard card in dictionary.Cards.Cards) { Assert.IsTrue(card.Box < 1, "Card box not resetted."); } foreach (IBox box in dictionary.Boxes.Box) { if (box.Id == 0) { Assert.AreEqual(dictionary.Cards.Cards.Count, box.CurrentSize, "Not all cards went to the Pool."); } else { Assert.AreEqual(0, box.CurrentSize, "Box is not empty."); } } Assert.AreEqual(0, dictionary.Score, "Score was not resetted."); Assert.AreEqual(0, dictionary.HighScore, "Highscore was not resetted."); } } }
public void IStatisticsLogAndSessionTest() { TestInfrastructure.DebugLineStart(TestContext); if (TestInfrastructure.IsActive(TestContext)) { using (IDictionary target = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser)) //Learning { if (target.Parent.CurrentUser.ConnectionString.Typ == DatabaseType.Xml) { return; } ICardsTests.FillDummyDic(target); Log.OpenUserSession(target.Id, target.Parent); for (int i = 0; i < 10; i++) { LearnLogStruct lls = new LearnLogStruct(); lls.SessionID = Log.LastSessionID; lls.CardsID = target.Cards.Cards[i].Id; lls.Answer = "testAnswer " + i; lls.CaseSensitive = i % 2 == 0 ? true : false; lls.CorrectOnTheFly = i % 2 == 0 ? true : false; lls.Direction = EQueryDirection.Mixed; lls.Duration = new TimeSpan(0, 0, 50).Ticks; lls.LearnMode = EQueryType.Word; lls.MoveType = i % 4 == 0 ? MoveType.AutoPromote : MoveType.AutoDemote; if (lls.MoveType == MoveType.AutoPromote) //promote { if (target.Cards.Cards[i].Box == 10) { lls.NewBox = 10; } else if (target.Cards.Cards[i].Box == 0) { lls.NewBox = 2; } else { lls.NewBox = target.Cards.Cards[i].Box + 1; } } else //demote { lls.NewBox = 1; } lls.OldBox = target.Cards.Cards[i].Box; lls.PercentageKnown = 100; lls.PercentageRequired = 50; lls.TimeStamp = DateTime.Now; Thread.Sleep(100); Log.CreateLearnLogEntry(lls, target.Parent); } Log.CloseUserSession(target.Parent); Thread.Sleep(250); Assert.AreEqual(1, target.Statistics.Count, "Dictionary.Statistics should contain ONE entry"); Assert.AreEqual(3, target.Statistics[0].Right, "Dictionary.Statistics[0].Right should contain the number 3."); Assert.AreEqual(7, target.Statistics[0].Wrong, "Dictionary.Statistics[0].Wrong should contain the number 7."); } } }