public void TestSavingRTFTextWorks() { Type TypeToTest = typeof(NoteDataXML_RichText); // 1. write data to notes _setupforlayoutests(); int count = 15; //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid"); FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); layoutPanel.NewLayout("testguid", true, null); NoteDataInterface note = null; for (int i = 0; i < count; i++) { note = (NoteDataInterface)Activator.CreateInstance(TypeToTest); //new NoteDataXML (); note.Caption = "boo" + i.ToString(); layoutPanel.AddNote(note); note.CreateParent(layoutPanel); } note = (NoteDataInterface)Activator.CreateInstance(TypeToTest); note.Caption = "snake"; string guid = note.GuidForNote; string teststring = "\nthe test is this "; note.Data1 = (@"{\rtf1\ansi\ansicpg1252\deff0\deflang4105{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}" + @"\viewkind4\uc1\pard\f0\fs17\par the test is this }"); // note.Data1=String.Format (@"{\rtf1\ansi\ansicpg1252\deff0\deflang4105{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs17\par {0} \par}", teststring); //"This is the story of the bird."; note.CreateParent(layoutPanel); _w.output("new guid" + guid); layoutPanel.AddNote(note); //layout.SaveTo (); layoutPanel.SaveLayout(); //layout = new FakeLayoutDatabase ("testguid"); layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); layoutPanel.LoadLayout("testguid", false, null); //layout.LoadFrom(layoutPanel); //_w.output(String.Format ("{0} Objects Loaded", layout.GetNotes().Count)); NoteDataInterface result = layoutPanel.GetLayoutDatabase().GetNoteByGUID(guid); string astest = ((NoteDataXML_RichText)result).GetAsText(); _w.output(result.Data1); _w.output(astest); Assert.AreEqual(teststring, astest); }
public void FindFileSimple() { //TestingSingleton.GetImageFile // Tests to see if it can find the file System.Windows.Forms.Form form = new System.Windows.Forms.Form(); _TestSingleTon.Instance._SetupForLayoutPanelTests(); LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataPicture), "pictures"); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panel); form.Show(); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.Caption = "note1"; panel.AddNote(basicNote); //basicNote.CreateParent(panel); //panel.MoveNote( FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel(); panelB.Caption = "PanelB"; panel.AddNote(panelA); panelA.CreateParent(panel); // b is inside A panelA.AddNote(panelB); panelB.CreateParent(panelA.GetPanelsLayout()); FAKE_NoteDataPicture picture = new FAKE_NoteDataPicture(); panelB.AddNote(picture); picture.CreateParent(panelB.GetPanelsLayout()); Assert.IsNull(picture.GetPictureBox().Image); Assert.True(System.IO.File.Exists(_TestSingleTon.ValidImageFile)); picture._SetImage(_TestSingleTon.ValidImageFile); Assert.IsNotNull(picture.GetPictureBox().Image); }
public void TestAddItemsToStoryboard() { _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); form.Controls.Add(panel); form.Show(); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.Caption = "note1"; panel.AddNote(basicNote); //basicNote.CreateParent(panel); NoteDataXML_GroupEm StoryBoard = new NoteDataXML_GroupEm(); panel.AddNote(StoryBoard); //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"; panel.AddNote(panelA); // 1 StoryBoard = new NoteDataXML_GroupEm(); StoryBoard.GuidForNote = "storyboard2"; StoryBoard.Caption = "storyboard"; panelA.AddNote(StoryBoard); StoryBoard.CreateParent(panelA.GetPanelsLayout()); Assert.AreEqual(0, StoryBoard.CountStoryBoardItems()); CoreUtilities.Links.LinkTableRecord record = new CoreUtilities.Links.LinkTableRecord(); record.sFileName = "PanelA"; //StoryBoard.GuidForNote; record.sKey = "*"; record.sText = "*"; record.sSource = StoryBoard.GuidForNote; panel.GetLinkTable().Add(record); Assert.AreEqual(1, panel.GetLinkTable().Count()); StoryBoard.Refresh(); Assert.AreEqual(1, StoryBoard.CountStoryBoardItems()); }
public void AddAndThenEditLinks() { // add a couple links, take count // then edit one of the early links a few times // get the link into a subpanel and make the counts are as expected _TestSingleTon.Instance._SetupForLayoutPanelTests(); // _SetupForLayoutPanelTests (); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); panel.SaveLayout(); // in this test we don't use the subpanel but just have it here for fun FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; panel.AddNote(panelA); panelA.CreateParent(panel); panel.SaveLayout(); System.Collections.Generic.List <string> linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel"); Assert.AreEqual(0, linkstome.Count); NoteDataXML_LinkNote link = new NoteDataXML_LinkNote(); panel.AddNote(link); link.CreateParent(panel); link.SetLink("mynewpanel.thisguid1"); panel.SaveLayout(); linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel"); Assert.AreEqual(1, linkstome.Count); // now edit the existing link link.SetLink("mynewpanel.thisguid2"); panel.SaveLayout(); Assert.AreEqual(1, linkstome.Count); // the counts should remain the same }
public void BuildReciprocalLinks() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); // _SetupForLayoutPanelTests (); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); panel.SaveLayout(); // #2 panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); panel.NewLayout("mynewpanel2", true, null); basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); panel.SaveLayout(); NoteDataXML_LinkNote note = new NoteDataXML_LinkNote(); panel.AddNote(note); note.CreateParent(panel); note.SetLink("mynewpanel.thisguid1"); panel.SaveLayout(); System.Collections.Generic.List <string> linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel2"); Assert.AreEqual(0, linkstome.Count); linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel"); Assert.AreEqual(1, linkstome.Count); }
public void TestDeleteNote() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); // add a note with specific label FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid"); layoutPanel.NewLayout("testguid", true, null); NoteDataXML_RichText note = new NoteDataXML_RichText(); string guid2find = ""; NoteDataInterface mynotetogo = null; for (int i = 0; i < 1; i++) { note.CreateParent(layoutPanel); note.Caption = "boo" + i.ToString(); note.UpdateLocation(); guid2find = note.GuidForNote; layoutPanel.AddNote(note); mynotetogo = note; } // layout.SaveTo(); layoutPanel.SaveLayout(); _w.output(guid2find); Assert.True(layoutPanel.GetLayoutDatabase().IsNoteExistsInLayout(guid2find)); _w.output("here"); // then delete it layoutPanel.GetLayoutDatabase().RemoveNote(mynotetogo); Assert.False(layoutPanel.GetLayoutDatabase().IsNoteExistsInLayout(guid2find)); }
public void TestReplaceWorks() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panel); // needed else DataGrid does not initialize form.Show(); //form.Visible = false; //NOTE: For now remember that htis ADDS 1 Extra notes string panelname = System.Guid.NewGuid().ToString(); panel.NewLayout(panelname, true, null); LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel"); FAKE_NoteDataXML_Text fakeTextNote = new FAKE_NoteDataXML_Text(); fakeTextNote.Caption = "Fake Text Note"; panel.AddNote(fakeTextNote); fakeTextNote.CreateParent(panel); // Won't actually add things properly because I need to override the findbar FAKE_FindBar findBar = new FAKE_FindBar(); form.Controls.Add(findBar); //RichTextExtended fakeText = new RichTextExtended(); //form.Controls.Add (fakeText); LayoutDetails.Instance.CurrentLayout = panel; LayoutDetails.Instance.CurrentLayout.CurrentTextNote = fakeTextNote; panel.SetFindBar(findBar); findBar.SupressMode = true; //!= null && LayoutDetails.Instance.CurrentLayout.CurrentTextNote != null fakeTextNote.GetRichTextBox().Text = "We have a dog. His name is Jake." + Environment.NewLine + "We love him a lot. And that cat. He is a nice dog. We all love dogs. Dogs are neat."; findBar.SetLastRichText(fakeTextNote.GetRichTextBox()); findBar.DoFind("dog", false, fakeTextNote.GetRichTextBox(), 0); //need to rewrite 'find/repalce' to make accessible better to test? It crashes. Assert.AreEqual(4, findBar.PositionsFOUND(), "Found 4 dogs"); findBar.Replace_Text("dog", "cat"); findBar.DoFind("dog", false, fakeTextNote.GetRichTextBox(), 0); Assert.AreEqual(0, findBar.PositionsFOUND(), "Found 0 dogs"); findBar.DoFind("cat", false, fakeTextNote.GetRichTextBox(), 0); Assert.AreEqual(5, findBar.PositionsFOUND(), "Found 5 cats. 4 replacements + 1 original"); }
public void AddLinkToSubpanel() { // get the link into a subpanel and make the counts are as expected _TestSingleTon.Instance._SetupForLayoutPanelTests(); // _SetupForLayoutPanelTests (); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); panel.SaveLayout(); FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; panel.AddNote(panelA); panelA.CreateParent(panel); panel.SaveLayout(); System.Collections.Generic.List <string> linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel"); Assert.AreEqual(0, linkstome.Count); NoteDataXML_LinkNote link = new NoteDataXML_LinkNote(); panelA.AddNote(link); link.CreateParent(panelA.GetPanelsLayout()); link.SetLink("mynewpanel.thisguid1"); panel.SaveLayout(); linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel"); Assert.AreEqual(1, linkstome.Count); }
public void DeleteTests() { // nest several panels //_SetupForLayoutPanelTests (); _TestSingleTon.Instance._SetupForLayoutPanelTests(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); panel.SaveLayout(); FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; panelA.GuidForNote = "panela"; panel.AddNote(panelA); panelA.CreateParent(panel); FAKE_NoteDataXML_Text textNote = new FAKE_NoteDataXML_Text(); panelA.AddNote(textNote); textNote.CreateParent(panelA.GetPanelsLayout()); textNote.Caption = "My text"; textNote.GetRichTextBox().Text = "Hello there."; panel.SaveLayout(); Assert.AreEqual(2, MasterOfLayouts.Count(true)); Assert.True(MasterOfLayouts.ExistsByGUID("mynewpanel")); MasterOfLayouts.DeleteLayout("mynewpanel"); Assert.False(MasterOfLayouts.ExistsByGUID("mynewpanel")); Assert.AreEqual(0, MasterOfLayouts.Count(true)); }
public void BasicInvokeTest() { SetupForSubmissionTest(); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panel); // needed else DataGrid does not initialize form.Show(); //form.Visible = false; _w.output("boom"); // March 2013 -- notelist relies on having this YOM2013.DefaultLayouts.CreateASystemLayout(form, null); LayoutDetails.Instance.SystemLayout = new Layout.LayoutPanel(CoreUtilities.Constants.BLANK, true); LayoutDetails.Instance.SystemLayout.LoadLayout(LayoutPanel.SYSTEM_LAYOUT, false, null); form.Controls.Add(LayoutDetails.Instance.SystemLayout); // we need to force a registeration event (may 2013) after I restructued how the // default tables are created MefAddIns.Addin_Submissions FAKESUBAddIn = new MefAddIns.Addin_Submissions(); FAKESUBAddIn.RegisterType(); //NOTE: For now remember that htis ADDS 1 Extra notes string panelname = System.Guid.NewGuid().ToString(); panel.NewLayout(panelname, true, null); LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanelZZ"); _w.output("herefirst"); NoteDataXML_Submissions Submissions = new NoteDataXML_Submissions(250, 250); Submissions.GuidForNote = "submissions"; Submissions.Caption = "Submissions"; panel.AddNote(Submissions); Submissions.CreateParent(panel); Submissions.UpdateAfterLoad(); panel.SaveLayout(); form.Dispose(); }
public void AlLFindBarsAreTheSame() { // children panels have the same findbar as a parent _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panel); // needed else DataGrid does not initialize form.Show(); //form.Visible = false; //NOTE: For now remember that htis ADDS 1 Extra notes string panelname = System.Guid.NewGuid().ToString(); panel.NewLayout(panelname, true, null); LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel"); FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.GuidForNote = "panelA"; panel.AddNote(panelA); //panel.AddNote(panelA); Intentionally do not add this because it should bea failre // Won't actually add things properly because I need to override the findbar FAKE_FindBar findBar = new FAKE_FindBar(); form.Controls.Add(findBar); RichTextExtended fakeText = new RichTextExtended(); form.Controls.Add(fakeText); fakeText.Text = "We have a dog. His name is Jake." + Environment.NewLine + "We love him a lot. He is a nice dog. We all love dogs."; findBar.DoFind("dog", false, fakeText, 0); Assert.AreEqual(panelA.GetPanelsLayout().GetFindbar(), panel.GetFindbar()); // Assert.AreEqual(panelB.GetPanelsLayout().GetFindbar(), panel.GetFindbar()); }
public void TestExistsByGUID() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); // _SetupForLayoutPanelTests (); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); panel.SaveLayout(); Assert.False(MasterOfLayouts.ExistsByGUID("mynewpanel2")); Assert.True(MasterOfLayouts.ExistsByGUID("mynewpanel")); }
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 TableSearch() { // the way filters work for tables is weird // and becaue it is weird I might tweak it later and this is a bad idea // so I'm writing this test to stop me from doing that _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); // needed else DataGrid does not initialize form.Show(); //form.Visible = false; _w.output("boom"); // March 2013 -- notelist relies on having this YOM2013.DefaultLayouts.CreateASystemLayout(form, null); //NOTE: For now remember that htis ADDS 1 Extra notes 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"); // ADD 1 of each type //foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) NoteDataXML_Table table = new NoteDataXML_Table(100, 100, new ColumnDetails[3] { new ColumnDetails("id", 100), new ColumnDetails("tables", 100), new ColumnDetails("values", 220) }); table.GuidForNote = "thetable"; table.Caption = "thettable2"; PanelOtherGuy.AddNote(table); table.CreateParent(PanelOtherGuy); // table.UpdateAfterLoad(); table.AddRow(new object[3] { "0", "table1", "value1" }); table.AddRow(new object[3] { "0", "table2", "value2" }); table.AddRow(new object[3] { "0", "table3", "value3" }); table.AddRow(new object[3] { "0", "table4", "value4" }); PanelOtherGuy.SaveLayout(); Assert.AreEqual(3, PanelOtherGuy.CountNotes(), "count2"); string ToSearchFor = "table3"; // looks in row 1 for the value and will return the value from row 2 List <string> results = PanelOtherGuy.GetListOfStringsFromSystemTable("thettable2", 2, String.Format("1|{0}", ToSearchFor)); Assert.NotNull(results); Assert.AreEqual(1, results.Count); Assert.AreEqual("value3", results[0]); ToSearchFor = "bacon"; results = PanelOtherGuy.GetListOfStringsFromSystemTable("thettable2", 2, String.Format("1|{0}", ToSearchFor)); Assert.NotNull(results); Assert.AreEqual(0, results.Count); ToSearchFor = "0"; results = PanelOtherGuy.GetListOfStringsFromSystemTable("thettable2", 1, String.Format("0|{0}", ToSearchFor)); Assert.NotNull(results); Assert.AreEqual(4, results.Count); }
public void ExportImport() { lg.Instance.OutputToConstoleToo = true; Form form = new Form(); string ThisLayoutGUID = "mynewpanelXA"; // create a layout _TestSingleTon.Instance._SetupForLayoutPanelTests(); // _SetupForLayoutPanelTests (); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panel); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout(ThisLayoutGUID, true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); //basicNote.CreateParent (panel); panel.SaveLayout(); FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; panelA.GuidForNote = "panela"; panel.AddNote(panelA); panelA.CreateParent(panel); FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel(); panelB.Caption = "PanelBBBBB2"; panelB.GuidForNote = "panelBB"; panelA.AddNote(panelB); panelB.CreateParent(panelA.GetPanelsLayout()); FAKE_NoteDataXML_Text textNoteA = new FAKE_NoteDataXML_Text(); panelB.AddNote(textNoteA); textNoteA.GuidForNote = "My Text Note For the B Panel"; textNoteA.CreateParent(panelB.GetPanelsLayout()); textNoteA.Caption = "My text B"; FAKE_NoteDataXML_Text textNote = new FAKE_NoteDataXML_Text(); panelA.AddNote(textNote); textNote.GuidForNote = "Text Note For Panel A"; textNote.CreateParent(panelA.GetPanelsLayout()); textNote.Caption = "My text A"; textNote.GetRichTextBox().Text = "Hello there." + Environment.NewLine + "I am still here, are you?" + Environment.NewLine + "Yep!"; panel.SaveLayout(); Assert.AreEqual(7, panel.CountNotes(), "Count1"); // Note count: Default Note + BasicNote+ PanelA + LinkTable + MyText + PanbelB + My Text B =7 //test existence Assert.True(MasterOfLayouts.ExistsByGUID(ThisLayoutGUID)); // counting our subpanel we have 2 Assert.AreEqual(3, MasterOfLayouts.Count(true)); // NOT counting our subpanel we have 1 Assert.AreEqual(1, MasterOfLayouts.Count(false)); // export string file = Path.Combine(Environment.CurrentDirectory, "exportest.txt"); if (File.Exists(file)) { File.Delete(file); } string subfile = file + "__child0.txt"; if (File.Exists(subfile)) { File.Delete(subfile); } string subfile2 = file + "__child1.txt"; if (File.Exists(subfile2)) { File.Delete(subfile2); } Assert.False(File.Exists(file), file + " does not exist"); MasterOfLayouts.ExportLayout(ThisLayoutGUID, file); // test exportfile existence // count 2 files exported Assert.True(File.Exists(file), "main file exists"); Assert.True(File.Exists(subfile), "subfile exists"); Assert.True(File.Exists(subfile2), "subfile2 exists"); // delete original note MasterOfLayouts.DeleteLayout(ThisLayoutGUID); // test existence Assert.False(MasterOfLayouts.ExistsByGUID(ThisLayoutGUID)); // counting our subpanel we have ZERO Assert.AreEqual(0, MasterOfLayouts.Count(true), "Nothing should be left"); // Import as New (but won't be duplicate because old is gone) int errorcode = MasterOfLayouts.ImportLayout(file); Console.WriteLine(errorcode); Assert.True(MasterOfLayouts.ExistsByGUID(ThisLayoutGUID)); // test existence // confirm all notes laoded into layout panel = null; panel = new FAKE_LayoutPanel(ThisLayoutGUID, false); form.Controls.Add(panel); panel.LoadLayout(ThisLayoutGUID, false, null); // panel.SaveLayout(); Assert.AreEqual(7, panel.CountNotes(), "Count2"); Assert.AreEqual(1, MasterOfLayouts.Count(false)); Assert.AreEqual(3, MasterOfLayouts.Count(true)); // Import as Overwrite if (File.Exists(file)) { File.Delete(file); } subfile = file + "__child0.txt"; if (File.Exists(subfile)) { File.Delete(subfile); } Assert.True(MasterOfLayouts.ExistsByGUID(ThisLayoutGUID)); MasterOfLayouts.ExportLayout(ThisLayoutGUID, file); panel = null; errorcode = MasterOfLayouts.ImportLayout(file); Assert.AreEqual(0, errorcode); // test existences panel = new FAKE_LayoutPanel(ThisLayoutGUID, false); form.Controls.Add(panel); panel.LoadLayout(ThisLayoutGUID, false, null); Assert.AreEqual(7, panel.CountNotes()); Assert.AreEqual(1, MasterOfLayouts.Count(false)); Assert.AreEqual(3, MasterOfLayouts.Count(true)); lg.Instance.OutputToConstoleToo = false; }
public void AnEmptyPanelStillHasAParent() { lg.Instance.OutputToConstoleToo = true; Form form = new Form(); string ThisLayoutGUID = "mynewpanelXA"; // create a layout _TestSingleTon.Instance._SetupForLayoutPanelTests(); // _SetupForLayoutPanelTests (); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panel); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout(ThisLayoutGUID, true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); //basicNote.CreateParent (panel); panel.SaveLayout(); FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; panelA.GuidForNote = "panela"; panel.AddNote(panelA); panelA.CreateParent(panel); FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel(); panelB.Caption = "PanelBBBBB"; panelB.GuidForNote = "panelBB"; panelA.AddNote(panelB); panelB.CreateParent(panelA.GetPanelsLayout()); FAKE_NoteDataXML_Text textNote = new FAKE_NoteDataXML_Text(); panelA.AddNote(textNote); textNote.CreateParent(panelA.GetPanelsLayout()); textNote.Caption = "My text"; textNote.GetRichTextBox().Text = "Hello there." + Environment.NewLine + "I am still here, are you?" + Environment.NewLine + "Yep!"; panel.SaveLayout(); Assert.AreEqual(6, panel.CountNotes()); _w.output(panelB.GetPanelsLayout().ParentGUID); // get parent GUID directlyf rom database FAKE_LayoutPanel SubPanelB = new FAKE_LayoutPanel("panelBB", true); form.Controls.Add(SubPanelB); SubPanelB.LoadLayout("panelBB", true, null); Assert.AreNotEqual(Constants.BLANK, SubPanelB.GetLayoutDatabase().ParentGuid); }