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"); } }
/// <summary> /// Copies a XML Learning Module to the database. /// </summary> /// <returns></returns> /// <remarks>Documented by Dev03, 2008-11-18</remarks> private void CopyLM() { if (!File.Exists(textBoxSource.Text)) { return; } ConnectionStringStruct connectionTarget; ConnectionStringStruct connectionSource = new ConnectionStringStruct(DatabaseType.Xml, textBoxSource.Text, false); int newLmId = dictionaries.AddNew(MLifter.DAL.Category.DefaultCategory, string.Empty).Id; connectionTarget = dictionaries.Parent.CurrentUser.ConnectionString; connectionTarget.LmId = importedId = newLmId; ShowStatusMessage(true); LearnLogic.CopyToFinished += new EventHandler(LearnLogic_CopyToFinished); try { LearnLogic.CopyLearningModule(connectionSource, connectionTarget, (GetLoginInformation)LoginForm.OpenLoginForm, (CopyToProgress)UpdateStatusMessage, (DataAccessErrorDelegate) delegate(object o, Exception ex) { return; }, m_learnLogic.User); } catch { HideStatusMessage(); //delete partially created dictionary dictionaries.Delete(connectionTarget); MessageBox.Show(Properties.Resources.DIC_ERROR_LOADING_TEXT, Properties.Resources.DIC_ERROR_LOADING_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void DoubleLoginTest() { if (TestInfrastructure.IsActive(TestContext)) { switch (TestInfrastructure.ConnectionType(TestContext)) { case "File": case "sqlce": throw new DoubleLoginException(); default: break; } ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionString(TestContext); LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate) delegate { return; }); learnLogic.User.Authenticate((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, connectionString, (DataAccessErrorDelegate) delegate { return; }); //Doesn't throw the Exception because the UserFactory logs out the previous user LearnLogic lLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate) delegate { return; }); lLogic.User.Authenticate((GetLoginInformation)GetLoginErrorMethod, connectionString, (DataAccessErrorDelegate) delegate { return; }); //Check instead if old user is logged out properly if (!learnLogic.UserSessionAlive) { throw new DoubleLoginException(); } } else { throw new DoubleLoginException(); } }
/// <summary> /// Registers the learn logic. /// </summary> /// <param name="learnlogic">The learnlogic.</param> /// <remarks>Documented by Dev02, 2008-04-22</remarks> public void RegisterLearnLogic(LearnLogic learnlogic) { this.learnlogic = learnlogic; this.learnlogic.CardStateChanged += new LearnLogic.CardStateChangedEventHandler(learnlogic_CardStateChanged); this.learnlogic.LearningModuleClosed += new EventHandler(learnlogic_LearningModuleClosed); this.learnlogic.LearnLogicIsWorking += new EventHandler(learnlogic_LearnLogicIsWorking); this.learnlogic.LearnLogicIdle += new EventHandler(learnlogic_LearnLogicIdle); }
public void OpenLearningModuleFileNotFoundTest() { LearnLogic llogic = new LearnLogic((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, (DataAccessErrorDelegate) delegate { return; }); LearningModulesIndexEntry module = new LearningModulesIndexEntry(); module.ConnectionString = new ConnectionStringStruct(DatabaseType.Xml, "invalid"); llogic.OpenLearningModule(module); }
/// <summary> /// Initializes a new instance of the <see cref="LMSelectionPage"/> class. /// </summary> /// <param name="learnLogic">The learn logic.</param> /// <param name="localLMDirectory">The local file open dialog start directory.</param> /// <param name="localLMOpenFilter">The local file open dialog filter mask.</param> /// <param name="localLMSaveFilter">The local LM save filter.</param> /// <remarks>Documented by Dev02, 2008-09-22</remarks> public LMSelectionPage(LearnLogic learnLogic, string localLMDirectory, string localLMOpenFilter, string localLMSaveFilter) { InitializeComponent(); listViewLMs_SelectedIndexChanged(listViewLMs, EventArgs.Empty); m_learnLogic = learnLogic; this.localLMDirectory = localLMDirectory; this.localLMOpenFilter = localLMOpenFilter; this.localLMSaveFilter = localLMSaveFilter; }
/// <summary> /// Initializes a new instance of the <see cref="ServerConnectorPage"/> class. /// </summary> /// <param name="learnLogic">The learn logic.</param> /// <remarks>Documented by Dev02, 2008-07-23</remarks> public ServerConnectorPage(LearnLogic learnLogic) { InitializeComponent(); #if DEBUG if (File.Exists(connectionstringfile)) { textBoxConnectionString.Text = File.ReadAllText(connectionstringfile); } #endif m_learnLogic = learnLogic; }
/// <summary> /// Runs a test for opening file types that throw exceptions. /// </summary> /// <param name="ext">The ext.</param> /// <remarks>Documented by Dev09, 2009-03-05</remarks> private void FileExtTestHelper(String ext) { // create temp file with desired extension String filename = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + "." + ext); File.Create(filename); LearnLogic llogic = new LearnLogic((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, (DataAccessErrorDelegate) delegate { return; }); LearningModulesIndexEntry module = new LearningModulesIndexEntry(); module.ConnectionString = new ConnectionStringStruct(DatabaseType.Xml, filename); llogic.OpenLearningModule(module); }
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; } } } }
/// <summary> /// Registers the learn logic. /// </summary> /// <param name="learnlogic">The learnlogic.</param> /// <remarks>Documented by Dev02, 2008-04-22</remarks> public void RegisterLearnLogic(LearnLogic learnlogic) { if (this.learnlogic == null || this.learnlogic != learnlogic) { this.learnlogic = learnlogic; RegisterLearnLogicAllControls(this.Controls); RegisterLearnLogicAllComponents(this.components.Components); this.Visible = learnlogic.DictionaryReadyForLearning; this.learnlogic.LearningModuleClosed += new EventHandler(learnlogic_LearningModuleClosed); this.learnlogic.LearningModuleOptionsChanged += new EventHandler(learnlogic_LearningModuleOptionsChanged); this.learnlogic.UserDialog += new LearnLogic.UserDialogEventHandler(learnlogic_UserDialog); this.learnlogic.OnLearningModuleOptionsChanged(); } }
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"); } }
public void Start(string filename, bool cleanUp) { System.Windows.Forms.Application.DoEvents(); cleanUpOdx = cleanUp; if (filename == (string)null) { throw new ArgumentNullException("filename"); } if (filename.Length == 0) { throw new ArgumentException("filename"); } try { ShowStatusMessage("Converting"); odxFile = filename; IUser xmlUser = UserFactory.Create((GetLoginInformation) delegate(UserStruct u, ConnectionStringStruct c) { return(u); }, new ConnectionStringStruct(DatabaseType.Xml, Path.GetDirectoryName(filename), filename, true), DataAccessError, this); IDictionary oldDic = xmlUser.Open(); IUser dbUser = UserFactory.Create((GetLoginInformation) delegate(UserStruct u, ConnectionStringStruct c) { return(u); }, new ConnectionStringStruct(DatabaseType.Unc, Path.GetDirectoryName(filename), Path.ChangeExtension(filename, Helper.EmbeddedDbExtension), true), DataAccessError, this); IDictionary newDic = dbUser.List().AddNew(oldDic.Category.Id > 5 ? 3 : oldDic.Category.Id, oldDic.Title); ConnectionStringStruct oldCon = new ConnectionStringStruct(DatabaseType.Xml, filename); ConnectionStringStruct newCon = new ConnectionStringStruct(DatabaseType.MsSqlCe, newDic.Connection, newDic.Id); edbFile = newCon.ConnectionString; oldDic.Dispose(); newDic.Dispose(); LearnLogic.CopyToFinished += new EventHandler(LearnLogic_CopyToFinished); LearnLogic.CopyLearningModule(oldCon, newCon, (GetLoginInformation) delegate(UserStruct u, ConnectionStringStruct c) { return(u); }, UpdateStatusMessage, DataAccessError, null); Dictionary = newCon.ConnectionString; } catch { HideStatusMessage(); throw; } }
/// <summary> /// Registers the learn logic. /// </summary> /// <param name="learnlogic">The learnlogic.</param> /// <remarks>Documented by Dev02, 2008-04-22</remarks> public void RegisterLearnLogic(LearnLogic learnlogic) { this.learnlogic = learnlogic; this.learnlogic.CardStateChanged += new LearnLogic.CardStateChangedEventHandler(learnlogic_CardStateChanged); }
/// <summary> /// Handles the Click event of the buttonExport control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-09-22</remarks> private void buttonExport_Click(object sender, EventArgs e) { if (SelectedLMId >= 0) { SaveFileDialog saveDialog = new SaveFileDialog(); if (localLMSaveFilter != string.Empty) { saveDialog.Filter = localLMSaveFilter; } if (localLMDirectory != string.Empty) { saveDialog.InitialDirectory = localLMDirectory; } saveDialog.FileName = listViewLMs.SelectedItems[0].Text; if (saveDialog.ShowDialog() == DialogResult.OK) { ConnectionStringStruct connectionSource = dictionaries.Parent.CurrentUser.ConnectionString; connectionSource.LmId = SelectedLMId; string filename = saveDialog.FileName; ConnectionStringStruct connectionTarget = new ConnectionStringStruct(DatabaseType.Xml, filename, true); //delete target LM if it already exists (=overwrite it) try { if (File.Exists(filename)) { File.Delete(filename); } } catch (System.IO.IOException) { MessageBox.Show(String.Format(Properties.Resources.DIC_ERROR_LOADING_LOCKED_TEXT, filename), Properties.Resources.DIC_ERROR_LOADING_LOCKED_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ShowStatusMessage(false); LearnLogic.CopyToFinished += new EventHandler(LearnLogic_CopyToFinished); try { LearnLogic.CopyLearningModule(connectionSource, connectionTarget, (GetLoginInformation)LoginForm.OpenLoginForm, (CopyToProgress)UpdateStatusMessage, (DataAccessErrorDelegate)DataAccessError, m_learnLogic.User); } catch { HideStatusMessage(); //delete partially created dictionary if (File.Exists(filename)) { File.Delete(filename); } MessageBox.Show(String.Format(Properties.Resources.DIC_ERROR_LOADING_TEXT, filename), Properties.Resources.DIC_ERROR_LOADING_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public Mainform(string[] args) { InitializeComponent(); m_learnLogic = new LearnLogic(GetUser, DataAccessError); }
/// <summary> /// Initializes a new instance of the <see cref="User"/> class. /// </summary> /// <param name="learnLogic">The learn logic.</param> /// <remarks>Documented by Dev09, 2009-04-10</remarks> public User(LearnLogic learnLogic) { CurrentLearnLogic = learnLogic; }
/// <summary> /// Handles the Click event of the buttonImport control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-09-22</remarks> private void buttonImport_Click(object sender, EventArgs e) { OpenFileDialog openDialog = new OpenFileDialog(); if (localLMOpenFilter != string.Empty) { openDialog.Filter = localLMOpenFilter; } if (localLMDirectory != string.Empty) { openDialog.InitialDirectory = localLMDirectory; } if (openDialog.ShowDialog() == DialogResult.OK) { string filename = openDialog.FileName; ConnectionStringStruct connectionSource = new ConnectionStringStruct(DatabaseType.Xml, filename, true); int newLmId = dictionaries.AddNew(MLifter.DAL.Category.DefaultCategory, string.Empty).Id; ConnectionStringStruct connectionTarget = dictionaries.Parent.CurrentUser.ConnectionString; connectionTarget.LmId = newLmId; ShowStatusMessage(true); LearnLogic.CopyToFinished += new EventHandler(LearnLogic_CopyToFinished); try { LearnLogic.CopyLearningModule(connectionSource, connectionTarget, (GetLoginInformation)LoginForm.OpenLoginForm, (CopyToProgress)UpdateStatusMessage, (DataAccessErrorDelegate)DataAccessError, m_learnLogic.User); } catch (DictionaryNotDecryptedException) { HideStatusMessage(); //delete partially created dictionary dictionaries.Delete(new ConnectionStringStruct(DatabaseType.PostgreSQL, string.Empty, newLmId)); UpdateList(); MessageBox.Show(Properties.Resources.DIC_ERROR_NOT_DECRYPTED_TEXT, Properties.Resources.DIC_ERROR_NOT_DECRYPTED_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (DictionaryContentProtectedException) { HideStatusMessage(); //delete partially created dictionary dictionaries.Delete(new ConnectionStringStruct(DatabaseType.PostgreSQL, string.Empty, newLmId)); UpdateList(); MessageBox.Show(string.Format(Properties.Resources.DIC_ERROR_CONTENTPROTECTED_TEXT, filename), Properties.Resources.DIC_ERROR_CONTENTPROTECTED_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (MLifter.DAL.InvalidDictionaryException) { HideStatusMessage(); //delete partially created dictionary dictionaries.Delete(new ConnectionStringStruct(DatabaseType.PostgreSQL, string.Empty, newLmId)); UpdateList(); MessageBox.Show(String.Format(Properties.Resources.DIC_ERROR_LOADING_TEXT, filename), Properties.Resources.DIC_ERROR_LOADING_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Xml.XmlException) { HideStatusMessage(); //delete partially created dictionary dictionaries.Delete(new ConnectionStringStruct(DatabaseType.PostgreSQL, string.Empty, newLmId)); UpdateList(); MessageBox.Show(String.Format(Properties.Resources.DIC_ERROR_LOADING_TEXT, filename), Properties.Resources.DIC_ERROR_LOADING_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.IO.IOException) { HideStatusMessage(); //delete partially created dictionary dictionaries.Delete(new ConnectionStringStruct(DatabaseType.PostgreSQL, string.Empty, newLmId)); UpdateList(); MessageBox.Show(String.Format(Properties.Resources.DIC_ERROR_LOADING_LOCKED_TEXT, filename), Properties.Resources.DIC_ERROR_LOADING_LOCKED_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch { HideStatusMessage(); //delete partially created dictionary dictionaries.Delete(new ConnectionStringStruct(DatabaseType.PostgreSQL, string.Empty, newLmId)); UpdateList(); MessageBox.Show(String.Format(Properties.Resources.DIC_ERROR_LOADING_TEXT, filename), Properties.Resources.DIC_ERROR_LOADING_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
void ILearnUserControl.RegisterLearnLogic(LearnLogic learnlogic) { this.learnlogic = learnlogic; this.learnlogic.CardStateChanged += new LearnLogic.CardStateChangedEventHandler(learnlogic_CardStateChanged); }
/// <summary> /// Initializes a new instance of the <see cref="TestDataGenerator"/> class. /// </summary> /// <param name="connectionString">The connection string.</param> /// <remarks>Documented by Dev03, 2008-11-28</remarks> internal TestDataGenerator(LearnLogic learnLogic) { m_learnLogic = learnLogic; }
/// <summary> /// Initializes a new instance of the <see cref="CardStack"/> class. /// </summary> /// <remarks>Documented by Dev02, 2008-05-05</remarks> public CardStack(LearnLogic currentLearnLogic) { learnLogic = currentLearnLogic; }
public void CopyToBasicTest() { //Perform Test only if we use a db connection otherwise test case makes no sense if (TestInfrastructure.IsActive(TestContext) && TestInfrastructure.ConnectionType(TestContext) != "File") { IUser sourceUser = null; IUser targetUser = null; try { string repositoryNameFinal = "finalTargetForCopyTest" + System.Environment.MachineName.ToLower(); //Do we have a target to copy from Assert.IsTrue(File.Exists(TestDic), "Test Learning Module file cannot be found."); ConnectionStringStruct sourceConnection = new ConnectionStringStruct(DatabaseType.Xml, CopyToTest.TestDic, false); sourceUser = UserFactory.Create((GetLoginInformation) delegate(UserStruct u, ConnectionStringStruct c) { return(u); }, sourceConnection, (DataAccessErrorDelegate) delegate { return; }, this); if (!authenticationUsers.ContainsKey(sourceConnection.ConnectionString)) { authenticationUsers.Add(sourceConnection.ConnectionString, sourceUser.AuthenticationStruct); } //Copy the reference LM to the new persistent LM ConnectionStringStruct dbConnection; using (Dictionary dbTarget = TestInfrastructure.GetConnection(TestContext)) { IUser dbUser = dbTarget.DictionaryDAL.Parent.CurrentUser; dbConnection = dbUser.ConnectionString; if (!authenticationUsers.ContainsKey(dbConnection.ConnectionString)) { authenticationUsers.Add(dbConnection.ConnectionString, dbUser.AuthenticationStruct); } dbTarget.Dispose(); finished = false; LearnLogic.CopyToFinished += new EventHandler(LearnLogic_CopyToFinished); LearnLogic.CopyLearningModule(sourceConnection, dbConnection, GetUser, (MLifter.DAL.Tools.CopyToProgress) delegate(string m, double p) { return; }, (DataAccessErrorDelegate) delegate { return; }, null); while (!finished) { System.Threading.Thread.Sleep(100); } ; LearnLogic.CopyToFinished -= new EventHandler(LearnLogic_CopyToFinished); } //copy to another persistent LM where we use Save to store as odx again ConnectionStringStruct targetConnection; using (Dictionary target = TestInfrastructure.GetPersistentLMConnection(TestContext, "sqlce")) { targetUser = target.DictionaryDAL.Parent.CurrentUser; targetConnection = targetUser.ConnectionString; if (!authenticationUsers.ContainsKey(targetConnection.ConnectionString)) { authenticationUsers.Add(targetConnection.ConnectionString, targetUser.AuthenticationStruct); } target.Dispose(); finished = false; LearnLogic.CopyToFinished += new EventHandler(LearnLogic_CopyToFinished); LearnLogic.CopyLearningModule(dbConnection, targetConnection, GetUser, (MLifter.DAL.Tools.CopyToProgress) delegate(string m, double p) { return; }, (DataAccessErrorDelegate) delegate { return; }, null); while (!finished) { System.Threading.Thread.Sleep(100); } ; LearnLogic.CopyToFinished -= new EventHandler(LearnLogic_CopyToFinished); } using (Dictionary source = new Dictionary(sourceUser.Open(), null)) using (Dictionary target = new Dictionary(targetUser.Open(), null)) { CompareChapters(source.Chapters.Chapters, target.Chapters.Chapters); //Verification Code compare finalTarget with the reference target CompareCards(source.Cards.Cards, target.Cards.Cards, source, target); //Compare Settings CompareSettings(source.Settings, target.Settings); if ((source.Settings != null) && (target.Settings != null)) { //Compare Styles CompareStyles(source.Settings.Style, target.Settings.Style); } } } finally { if (sourceUser != null) { sourceUser.Logout(); } if (targetUser != null) { targetUser.Logout(); } } } }
/// <summary> /// Registers the learn logic to this control. /// </summary> /// <param name="learnlogic">The learnlogic.</param> /// <remarks>Documented by Dev02, 2008-04-22</remarks> /// <remarks>Documented by Dev02, 2008-04-29</remarks> public void RegisterLearnLogic(MLifter.BusinessLayer.LearnLogic learnlogic) { this.learnlogic = learnlogic; this.learnlogic.UserDialog += new LearnLogic.UserDialogEventHandler(learnlogic_UserDialog); }
public void OpenLearningModuleNullTest() { LearnLogic llogic = new LearnLogic((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, (DataAccessErrorDelegate) delegate { return; }); llogic.OpenLearningModule(null); }
/// <summary> /// Registers the learn logic. /// </summary> /// <param name="learnlogic">The learnlogic.</param> /// <remarks>Documented by Dev02, 2008-04-22</remarks> public void RegisterLearnLogic(LearnLogic learnlogic) { this.learnlogic = learnlogic; this.oldCardStackVisibleValue = learnlogic.CardStack.VisibleStack.Count; this.learnlogic.CardStack.StackChanged += new EventHandler(CardStack_StackChanged); }