public void DeleteAllStatisticsTest() { if (TestInfrastructure.IsActive(TestContext)) { ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext); LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate) delegate { return; }); try { learnLogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString)); } catch (IsOdxFormatException) { if (TestInfrastructure.ConnectionType(TestContext) == "File") { return; } else { throw; } } learnLogic.OnLearningModuleOptionsChanged(); learnLogic.ResetLearningProgress(); LearnStats learnStats = learnLogic.Dictionary.Statistics.GetCurrentStats(); Assert.AreEqual <int>(0, learnStats.NumberOfRights, "DeleteAllStatistics() did not delete all Stats!"); Assert.AreEqual <int>(0, learnStats.NumberOfWrongs, "DeleteAllStatistics() did not delete all Stats!"); Assert.IsTrue(learnLogic.Dictionary.Statistics.GetNewestStatistic().StartTimestamp == learnLogic.Dictionary.Statistics.GetOldestStatistic().StartTimestamp, "GetNewestStatistic() and GetOldestStatistic seems to be not equal. There should be only ONE stat in the restarted LM"); } }
public void LearnLogicLearnModeTest() { if (TestInfrastructure.IsActive(TestContext)) { ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext); LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate) delegate { return; }); //learnLogic.User.Authenticate(OpenUserProfileTests.GetUserAdmin, connectionString, (DataAccessErrorDelegate)delegate { return; }); try { learnLogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString)); } catch (IsOdxFormatException) { if (TestInfrastructure.ConnectionType(TestContext) == "File") //success { return; } else { throw; } } learnLogic.User.Dictionary.Settings.QueryTypes.ImageRecognition = true; learnLogic.User.Dictionary.Settings.QueryTypes.ListeningComprehension = true; learnLogic.User.Dictionary.Settings.QueryTypes.Sentence = true; for (int i = 0; i < TestInfrastructure.LoopCount; i++) { learnLogic.OnLearningModuleOptionsChanged(); Card card = learnLogic.User.Dictionary.Cards.GetCardByID(learnLogic.CurrentCardID); switch (learnLogic.User.Dictionary.LearnMode) { case LearnModes.ImageRecognition: Assert.IsTrue(card.ContainsImage(Side.Question.ToString()), "Card must contain image for ImageRecognition mode."); break; case LearnModes.ListeningComprehension: Assert.IsTrue(card.ContainsAudio(Side.Question.ToString()), "Card must contain audio for ListeningComprehension mode."); break; case LearnModes.Sentence: Assert.IsTrue(card.CurrentQuestionExample.Words.Count > 0, "Card must contain example for Sentence mode."); break; default: continue; } } } }
public void GetBoxContentTest() { if (TestInfrastructure.IsActive(TestContext)) { ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext); LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate) delegate { return; }); //learnLogic.User.Authenticate((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, // connectionString, (DataAccessErrorDelegate)delegate { return; }); try { learnLogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString)); } catch (IsOdxFormatException) { if (TestInfrastructure.ConnectionType(TestContext) == "File") { return; } else { throw; } } learnLogic.OnLearningModuleOptionsChanged(); learnLogic.ResetLearningProgress(); Card currentCard = learnLogic.Dictionary.Cards.GetCardByID(learnLogic.CurrentCardID); //Answer Card correct UserInputSubmitEventArgs e = new UserInputSubmitTextEventArgs(0, currentCard.CurrentAnswer.Words.Count, currentCard.CurrentAnswer.Words.Count, true, currentCard.CurrentAnswer.Words.ToString()); learnLogic.OnUserInputSubmit(this, e); learnLogic.OnUserInputSubmit(this, new UserInputSubmitEventArgs()); Assert.AreEqual <int>(1, learnLogic.Dictionary.Statistics.GetBoxContent(2, DateTime.Now.AddDays(1)), "GetBoxContent() did not return the correct number of cards"); for (int i = 1; i < 10; i++) { if (i == 2) { continue; } else { Assert.AreEqual <int>(0, learnLogic.Dictionary.Statistics.GetBoxContent(i, DateTime.Now.AddDays(1)), "GetBoxContent() says the Box " + i + " is NOT 0 (although it should)"); } } } }
public void OpenLearningModuleCannotCloseTest() { if (TestInfrastructure.IsActive(TestContext) && TestInfrastructure.ConnectionType(TestContext).ToLower() != "file") { LearnLogic llogic = new LearnLogic((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, (DataAccessErrorDelegate) delegate { return; }); LearningModulesIndexEntry module = new LearningModulesIndexEntry(); module.ConnectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext); llogic.LearningModuleClosing += new LearnLogic.LearningModuleClosingEventHandler(llogic_LearningModuleClosing); llogic.OpenLearningModule(module); llogic.OpenLearningModule(module); } else { throw new CouldNotCloseLearningModuleException(); } }
public void GradeCardTest() { if (TestInfrastructure.IsActive(TestContext)) { ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext); LearnLogic llogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate) delegate { return; }); //llogic.User.Authenticate((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, // connectionString, (DataAccessErrorDelegate)delegate { return; }); try { llogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString)); } catch (IsOdxFormatException) { if (TestInfrastructure.ConnectionType(TestContext) == "File") { return; } else { throw; } } llogic.OnLearningModuleOptionsChanged(); Card card = llogic.Dictionary.Cards.GetCardByID(llogic.CurrentCardID); int oldBox = card.BaseCard.Box = 5; UserInputSubmitEventArgs e = new UserInputSubmitTextEventArgs(0, card.CurrentAnswer.Words.Count, card.CurrentAnswer.Words.Count, true, card.CurrentAnswer.Words.ToString()); llogic.OnUserInputSubmit(this, e); Assert.AreEqual <int>(oldBox + 1, card.BaseCard.Box, "Card was not correctly promoted!"); card.BaseCard.Box = oldBox; e = new UserInputSubmitTextEventArgs(5, 0, 5, false, string.Empty); llogic.OnUserInputSubmit(this, e); Assert.AreEqual <int>(1, card.BaseCard.Box, "Card was not demoted!"); } }
public void GetCurrentStatsTest() { if (TestInfrastructure.IsActive(TestContext)) { ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext); LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate) delegate { return; }); try { learnLogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString)); } catch (IsOdxFormatException) { if (TestInfrastructure.ConnectionType(TestContext) == "File") { return; } else { throw; } } learnLogic.OnLearningModuleOptionsChanged(); learnLogic.Dictionary.ResetLearningProgress(); //Answer Card correct Card currentCard = learnLogic.Dictionary.Cards.GetCardByID(learnLogic.CurrentCardID); UserInputSubmitEventArgs e = new UserInputSubmitTextEventArgs(0, currentCard.CurrentAnswer.Words.Count, currentCard.CurrentAnswer.Words.Count, true, currentCard.CurrentAnswer.Words.ToString()); learnLogic.OnUserInputSubmit(this, e); learnLogic.OnUserInputSubmit(this, new UserInputSubmitEventArgs()); //Answer Card wrong currentCard = learnLogic.Dictionary.Cards.GetCardByID(learnLogic.CurrentCardID); e = new UserInputSubmitTextEventArgs(0, 0, currentCard.CurrentAnswer.Words.Count, false, string.Empty); learnLogic.OnUserInputSubmit(this, e); learnLogic.OnUserInputSubmit(this, new UserInputSubmitEventArgs()); LearnStats stats = learnLogic.Dictionary.Statistics.GetCurrentStats(); Assert.AreEqual <int>(1, stats.NumberOfRights, "GetCurrentStats() did not return the correct LearnStats.NumberOfRights"); Assert.AreEqual <int>(1, stats.NumberOfWrongs, "GetCurrentStats() did not return the correct LearnStats.NumberOfWrongs"); } }