Exemple #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");
            }
        }
Exemple #2
0
        public void GetKnownTest()
        {
            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();

                //Answer 5 cards correct
                for (int i = 0; i < 5; i++)
                {
                    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());
                }

                int known = learnLogic.Dictionary.Statistics.GetKnown(DateTime.Now.AddDays(1));
                Assert.AreEqual<int>(5, known, "GetKnown() did not return the correct number of known cards");
            }
        }