Ejemplo n.º 1
0
        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");
            }
        }
Ejemplo n.º 2
0
        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");
            }
        }