public void GetListOfLayoutTests() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); form.Show(); // March 2013 -- notelist relies on having this YOM2013.DefaultLayouts.CreateASystemLayout(form, null); string panelname2 = System.Guid.NewGuid().ToString(); FAKE_LayoutPanel PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); PanelOtherGuy.NewLayout(panelname2, true, null); form.Controls.Add(PanelOtherGuy); PanelOtherGuy.SaveLayout(); Assert.AreEqual(2, PanelOtherGuy.CountNotes(), "count1"); List <MasterOfLayouts.NameAndGuid> names = MasterOfLayouts.GetListOfLayouts("WritingProjects"); Assert.AreEqual(0, names.Count); // 1 prtoject PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); PanelOtherGuy.NewLayout("NextLayout", true, null); PanelOtherGuy.SetCaption("booler"); PanelOtherGuy.SetNotebookSection("Writing", "Projects"); form.Controls.Add(PanelOtherGuy); PanelOtherGuy.SaveLayout(); names = MasterOfLayouts.GetListOfLayouts("WritingProjects"); Assert.AreEqual(1, names.Count); // search LIKE NAME PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); PanelOtherGuy.NewLayout("NextLayout22", true, null); PanelOtherGuy.SetCaption("boolAt"); LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text), "textfake"); FAKE_NoteDataXML_Text richy = new FAKE_NoteDataXML_Text(); PanelOtherGuy.AddNote(richy); richy.CreateParent(PanelOtherGuy); richy.GetRichTextBox().Text = "Hello there"; PanelOtherGuy.SetNotebookSection("Writing", "Projects"); form.Controls.Add(PanelOtherGuy); PanelOtherGuy.SaveLayout(); PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); PanelOtherGuy.NewLayout("NextLayout33", true, null); PanelOtherGuy.SetCaption("bolzzz"); PanelOtherGuy.SetNotebookSection("Writing", "Projects"); form.Controls.Add(PanelOtherGuy); PanelOtherGuy.SaveLayout(); names = MasterOfLayouts.GetListOfLayouts("WritingProjects"); Assert.AreEqual(3, names.Count); names = MasterOfLayouts.GetListOfLayouts("WritingProjects", "bool", false, null); Assert.AreEqual(2, names.Count); // // text searching // PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); PanelOtherGuy.NewLayout("NextLayout55", true, null); PanelOtherGuy.SetCaption("bolzzz222"); PanelOtherGuy.SetNotebookSection("Writing", "Projects"); form.Controls.Add(PanelOtherGuy); PanelOtherGuy.SaveLayout(); richy = new FAKE_NoteDataXML_Text(); PanelOtherGuy.AddNote(richy); richy.CreateParent(PanelOtherGuy); richy.GetRichTextBox().Text = "Hello there again!"; PanelOtherGuy.SaveLayout(); richy = new FAKE_NoteDataXML_Text(); PanelOtherGuy.AddNote(richy); richy.CreateParent(PanelOtherGuy); richy.GetRichTextBox().Text = "Hello the fish are good there"; PanelOtherGuy.SaveLayout(); names = MasterOfLayouts.GetListOfLayouts("All", "fish", true, null); Assert.AreEqual(1, names.Count); // FINAL TEST now count all names = MasterOfLayouts.GetListOfLayouts("All"); Assert.AreEqual(6, names.Count); // now test to see if text in a subpanel is found correct FAKE_NoteDataXML_Panel subpanel = new FAKE_NoteDataXML_Panel(); PanelOtherGuy.AddNote(subpanel); subpanel.CreateParent(PanelOtherGuy); names = MasterOfLayouts.GetListOfLayouts("All", "sharks", true, null); Assert.AreEqual(0, names.Count); FAKE_NoteDataXML_Text Rich2 = new FAKE_NoteDataXML_Text(); subpanel.AddNote(Rich2); Rich2.GetRichTextBox().Text = "Sharks"; PanelOtherGuy.SaveLayout(); names = MasterOfLayouts.GetListOfLayouts("All", "sharks", true, null); Assert.AreEqual(1, names.Count); }
public void MoveNoteOutOfParent_SaveShouldHappenAutomatically() { _w.output("START"); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); _TestSingleTon.Instance._SetupForLayoutPanelTests(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); LayoutDetails.Instance.CurrentLayout = panel; form.Controls.Add(panel); form.Show(); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); panel.SetCaption("TheMainPanel"); NoteDataXML basicNote = new NoteDataXML(); basicNote.Caption = "note1"; panel.AddNote(basicNote); //basicNote.CreateParent(panel); //panel.MoveNote( // create four panels A and B at root level. C inside A. D inside C FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; panelA.GuidForNote = "panela"; FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel(); panelB.Caption = "PanelB"; panelB.GuidForNote = "panelb"; FAKE_NoteDataXML_Panel panelC = new FAKE_NoteDataXML_Panel(); panelC.Caption = "PanelC"; panelC.GuidForNote = "panelc"; _w.output("panels made"); panel.AddNote(panelA); // 1 panel.AddNote(panelB); // 2 //panelA.CreateParent(panel); should not need to call this when doing LayoutPanel.AddNote because it calls CreateParent insid eof it basicNote = new NoteDataXML(); basicNote.Caption = "note2"; panelA.AddNote(basicNote); // Panel A has 1 note basicNote.CreateParent(panelA.myLayoutPanel()); // DO need to call it when adding notes like this (to a subpanel, I think) basicNote.BringToFrontAndShow(); NoteDataXML_RichText textNote = new NoteDataXML_RichText(); textNote.Caption = "howdy"; // ((FAKE_LayoutPanel)panelA.GetPanelsLayout()).SetCaption("boohowcrashmenow"); panelA.AddNote(textNote); textNote.CreateParent(panelA.myLayoutPanel()); textNote.BringToFrontAndShow(); textNote.TestEnter(); panelA.GetPanelsLayout().TestForceError(); // the current layout can never be set to a subplayout Assert.AreNotEqual(panelA.GetPanelsLayout(), LayoutDetails.Instance.CurrentLayout, "the current layout can never be set to a subplayout"); panel.SaveLayout(); Assert.AreEqual(2, panelA.CountNotes(), "Panel A holds TWo note"); // So this counts as + 2 // so we have (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6 _w.output("STARTCOUNT"); Assert.AreEqual(7, panel.CountNotes(), "Total notes SHOULD BE 7 : (1 + 1 note on it)panel A + (1+1textnote)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); _w.output("ENDCOUNT"); // now we move basicNote out // WITOUT calling save **** // it should still ahve saved panelA.myLayoutPanel().MoveNote(basicNote.GuidForNote, "up"); Assert.AreEqual(1, panelA.CountNotes(), "Panel A holds 1 note -- because we moved one out"); Assert.AreEqual(7, panel.CountNotes(), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); panel = null; panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); panel.LoadLayout("mynewpanel", false, null); //Assert.AreEqual (0, panelA.CountNotes (), "Panel A holds one note"); Assert.AreEqual(7, panel.CountNotes(), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); }
public void TestRemoteFactParse() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); LayoutDetails.Instance.AddToList(typeof(ADD_Facts.NoteDataXML_Facts), "factsfromtest"); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); // // #1 - Creating SOURCE layout // //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); panel.SetCaption("SourcePanel"); Assert.AreEqual("SourcePanel", panel.Caption); NoteDataXML_RichText basicNote = new NoteDataXML_RichText(); basicNote.GuidForNote = "chapter1"; basicNote.Caption = "chapter1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); basicNote.SelectedText = "The dog runs[[dog]] fast.\n\t But we don't love him[[snake]]. We love aliens[[alien]]."; //Assert.AreEqual(basicNote.GetAsText(), "The dog runs[[dog]] fast.\n But we don't love him. We love aliens[[alien]]."); NoteDataXML_RichText basicNote2 = new NoteDataXML_RichText(); basicNote2.GuidForNote = "chapter2"; basicNote2.Caption = "chapter2"; panel.AddNote(basicNote2); basicNote2.CreateParent(panel); basicNote2.SelectedText = "The cat runs[[cat]] fast.\n But we don't love him. \n\n\tWe love dogs[[dog]]."; Assert.AreEqual(basicNote2.GetAsText(), "The cat runs[[cat]] fast.\n But we don't love him. \n\n\tWe love dogs[[dog]]."); panel.SaveLayout(); NoteDataXML_GroupEm storyboard = new NoteDataXML_GroupEm(); storyboard.GuidForNote = "storyboard"; storyboard.Caption = "Storyboard"; panel.AddNote(storyboard); storyboard.CreateParent(panel); panel.SaveLayout(); Assert.AreEqual(5, panel.Count(), "why 5? Linktable + 3 should be 4? Nope: Rmemeber there is always a default note created too"); Assert.AreEqual(0, storyboard.GetGroups().Count); Assert.AreEqual(0, storyboard.CountStoryBoardItems()); storyboard.AddRecordDirectly("chapter1", basicNote.GuidForNote, "Chapters 1"); Assert.AreEqual(1, storyboard.CountStoryBoardItems(), "We only added 1 record but group counts as a second?"); storyboard.AddRecordDirectly("chapter2", basicNote2.GuidForNote, "Chapters 1"); Assert.AreEqual(2, storyboard.CountStoryBoardItems(), "We only added 1 record but group counts as a second?"); Assert.AreEqual(1, storyboard.GetGroups().Count); panel.SaveLayout(); // // #2 - Creating DESTINATION layout -- this is where we invoke the FACT search on Layout #1 // FAKE_LayoutPanel panel2 = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); panel2.NewLayout("mynewpanel2", true, null); ADD_Facts.NoteDataXML_Facts fact = new ADD_Facts.NoteDataXML_Facts(); fact.GuidForNote = "factnote"; fact.Caption = "Fact"; panel2.AddNote(fact); fact.CreateParent(panel2); panel2.SaveLayout(); Assert.AreEqual(3, panel2.Count(), "Default note + fact + linktable = 3"); NoteDataXML_RichText basicNote3 = new NoteDataXML_RichText(); basicNote3.GuidForNote = "factsource"; basicNote3.Caption = "Fact Source"; panel2.AddNote(basicNote3); basicNote3.CreateParent(panel2); basicNote3.SelectedText = "SourcePanel;[[Group,Storyboard,Chapters*,*]]"; panel2.SaveLayout(); Assert.AreEqual(4, panel2.Count(), "Default note + fact + linktable = 3"); // intentionally testing this from the previous layout just incase somethingw eird has happened Assert.AreEqual(basicNote2.GetAsText(), "The cat runs[[cat]] fast.\n But we don't love him. \n\n\tWe love dogs[[dog]]."); // 06Anobreak;[[Group,Storyboard,Chapters*,*]] // 06Bnobreak;[[Group,Storyboard,Chapters*,*]] string FactParseNote = "Fact Source"; NoteDataXML_RichText note = (NoteDataXML_RichText)panel2.FindNoteByName(FactParseNote); Assert.NotNull(note); string textFromNote = note.GetAsText(); Assert.AreEqual("SourcePanel;[[Group,Storyboard,Chapters*,*]]", textFromNote); // now attempt the Fact Parse List <string> results = new List <string>(); int error = fact.StartFactGathering(ref results, textFromNote); Assert.AreEqual(0, error, "first pass"); Assert.NotNull(results); Assert.AreEqual(0, results.Count, "How many matching facts found"); fact.SetTag("dog"); Assert.AreEqual("dog", fact.Token); fact.SetSaveRequired(true); panel2.SaveLayout(); Assert.AreEqual("dog", fact.Token); //Assert.AreEqual(2,results.Count, "How many matching facts found. THIS SHOULD FAIL -- we have no markup assigned"); YourOtherMind.iMarkupYourOtherMind markup = new YourOtherMind.iMarkupYourOtherMind(); LayoutDetails.Instance.AddMarkupToList(markup); LayoutDetails.Instance.SetCurrentMarkup(markup); Assert.AreEqual("YourOtherMind", LayoutDetails.Instance.GetCurrentMarkup().ToString()); results = new List <string>(); error = fact.StartFactGathering(ref results, textFromNote); Assert.AreEqual(0, error, "second pass"); Assert.AreEqual(2, results.Count, "How many matching facts found. Now that we have setup tag"); fact.SetTag("cat"); results = new List <string>(); error = fact.StartFactGathering(ref results, textFromNote); Assert.AreEqual(1, results.Count, "How many matching facts found. Now that we have setup tag"); fact.SetTag("fish"); results = new List <string>(); error = fact.StartFactGathering(ref results, textFromNote); Assert.AreEqual(0, results.Count, "How many matching facts found. Now that we have setup tag"); fact.SetTag("alien"); results = new List <string>(); error = fact.StartFactGathering(ref results, textFromNote); Assert.AreEqual(1, results.Count, "How many matching facts found. Now that we have setup tag"); }