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 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 GetListOfStringsInColumn() { // nest several panels _SetupForLayoutPanelTests (); Form form = new Form(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); form.Controls.Add (panel); // needed else DataGrid does not initialize form.Visible = false; form.Show (); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout ("mynewpanel", true, null); NoteDataXML_Table test = new NoteDataXML_Table (425, 380); test.GuidForNote = "thisguid1"; test.Caption = "note1"; panel.SaveLayout (); // test.Columns = new appframe.ColumnDetails[3] {new appframe.ColumnDetails("snakes", 109), new appframe.ColumnDetails("fish", 90), new appframe.ColumnDetails("goobers", 11111)}; panel.AddNote (test); test.CreateParent (panel); _w.output ("COLUMN "+test.Columns.Length.ToString()); Assert.AreEqual (4, test.Columns.Length,"before save"); // saving is deleting the columns?! panel.SaveLayout (); Assert.AreEqual (4, test.Columns.Length, "after save"); for (int i = 0; i < 4; i ++) { switch (i) { case 0: Assert.AreEqual("Roll", test.Columns[i].ColumnName); break; case 1: Assert.AreEqual("Result", test.Columns[i].ColumnName); break; case 2: Assert.AreEqual("Next Table", test.Columns[i].ColumnName); break; case 3: Assert.AreEqual("Modifier", test.Columns[i].ColumnName); break; } } // not sure what we are testin here [The default Columns?] // testing notedataxml_table }
public void TestDefaultHeightAndWidth() { // nest several panels _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 test = new NoteDataXML(425,380); test.GuidForNote = "thisguid1"; test.Caption = "note1"; panel.AddNote(test); test.CreateParent(panel); panel.SaveLayout(); Assert.AreEqual (test.Height, 425); Assert.AreEqual (test.Width, 380); }
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 CopyToClipboard() { // Table // Roll Result NextTable Modifier ff seer eee // z. This is a test. How to do al inefeed,,,length,,, // beer.This is the story that never was,e,,,bb,, _TestSingleTon.Instance._SetupForLayoutPanelTests(); Form form = new 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 panel.NewLayout ("mynewpanel", true, null); FAKE_NoteDataXML_Table test = new FAKE_NoteDataXML_Table (33,0009); test.GuidForNote = "thisguid1"; test.Caption = "note1"; test.CreateParent(panel); test.AddRow(new object[3] {"1", "value1", "testA"}); test.AddRow(new object[3] {"2", "value2", "testB"}); test.AddRow(new object[3] {"3", "value3", "testC"}); panel.SaveLayout (); test.Copy (); string result = Clipboard.GetText(); Assert.AreEqual(91, result.Length); form.Dispose (); }
public void GetValuesForTable() { _SetupForLayoutPanelTests (); Form form = new Form(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); form.Controls.Add (panel); // needed else DataGrid does not initialize form.Visible = false; form.Show (); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout ("mynewpanel", true, null); NoteDataXML_Table test = new NoteDataXML_Table (425, 380); test.GuidForNote = "thisguid1"; test.Caption = "note1"; test.Columns = new ColumnDetails[3] { new ColumnDetails ("snakes", 109), new ColumnDetails ("fish", 90), new ColumnDetails ("goobers", 11111) }; test.AddRow(new object[3] {"1", "value1", "testA"}); test.AddRow(new object[3] {"2", "value2", "testB"}); test.AddRow(new object[3] {"3", "value3", "testC"}); panel.AddNote (test); test.CreateParent (panel); panel.SaveLayout (); List<string> cols = test.GetValuesForColumn (1,"*"); for (int i = 0; i <3; i++) { switch (i) { case 0: Assert.AreEqual(cols[i], "value1"); break; case 1:Assert.AreEqual(cols[i], "value2"); break; case 2: Assert.AreEqual(cols[i], "value3"); break; } } cols = test.GetValuesForColumn (2,"*"); for (int i = 0; i <3; i++) { switch (i) { case 0: Assert.AreEqual(cols[i], "testA"); break; case 1:Assert.AreEqual(cols[i], "testB"); break; case 2: Assert.AreEqual(cols[i], "testC"); break; } } }
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 DeleteTest() { _setupforlayoutests (); Assert.False (MasterOfLayouts.ExistsByGUID("DeleteMe")); //FakeLayoutDatabase layout = new FakeLayoutDatabase ("DeleteMe"); FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); layoutPanel.NewLayout("DeleteMe",true, null); //LayoutDatabase layout = layoutPanel.GetLayoutDatabase(); //layout.SaveTo (); layoutPanel.SaveLayout (); Assert.True (MasterOfLayouts.ExistsByGUID("DeleteMe")); MasterOfLayouts.DeleteLayout ("DeleteMe"); Assert.False (MasterOfLayouts.ExistsByGUID("DeleteMe")); layoutPanel.Dispose(); }
public void ImportListTest_UnequalColumns() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); Form form = new 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 panel.NewLayout ("mynewpanel", true, null); NoteDataXML_Table test = new NoteDataXML_Table (425, 380); test.GuidForNote = "thisguid1"; test.Caption = "note1"; panel.SaveLayout (); string[] newData = new string[3]{"1,col2,col3","2,col2,col3","3,col2,col3"}; TableWrapper.ImportList(newData, (DataTable)test.dataSource); panel.SaveLayout(); List<string> values = test.GetValuesForColumn(1, "*"); Assert.AreEqual (3, values.Count); Assert.AreEqual ("1,col2,col3", values[0]); form.Dispose (); }
public void IterateBigDatabase() { _TestSingleTon.Instance.SetupForAnyTest (); LayoutDetails.Instance.YOM_DATABASE =@"C:\Users\BrentK\Documents\Projects\Utilities\yom2013B\zUnitTestsForSolution\bin\Debug\yomBIGGY.s3db"; LayoutDetails.Instance.OverridePath = Environment.CurrentDirectory; LayoutDetails.Instance.GetAppearanceFromStorage = _TestSingleTon.Instance.GetAppearanceFromStorage; LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel),"testingpanel"); LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text),"testingtext"); FakeLayoutDatabase layout = new FakeLayoutDatabase("testguid"); FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase(layout.GetDatabaseName ()); LayoutDetails.Instance.SuppressWarnings = true; /// want image missing popups not to bug us LayoutDetails.Instance.AddToList(typeof(NoteDataXML_Picture.NoteDataXML_Pictures), "picture"); LayoutDetails.Instance.AddToList(typeof(MefAddIns.NoteDataXML_SendIndex), "index"); LayoutDetails.Instance.AddToList(typeof(MefAddIns.NoteDataXML_Submissions), "index"); LayoutDetails.Instance.TransactionsList =new Transactions.TransactionsTable(MasterOfLayouts.GetDatabaseType(LayoutDetails.Instance.YOM_DATABASE)); Form form = new Form(); // system panel // LayoutPanel panel = new LayoutPanel("", false); // panel.LoadLayout("system", false, null); FAKE_LayoutPanel system = new FAKE_LayoutPanel("", false); form.Controls.Add(system); system.LoadLayout("system", false, null); LayoutDetails.Instance.SystemLayout = system; FAKE_LayoutPanel tablelay = new FAKE_LayoutPanel("", false); form.Controls.Add(tablelay); tablelay.LoadLayout ("tables", false, null); LayoutDetails.Instance.TableLayout = tablelay; // YOM2013.DefaultLayouts.CreateASystemLayout(form,null); // string ThisLayoutGUID = "mynewpanelXA"; // create a layout // _TestSingleTon.Instance._SetupForLayoutPanelTests (false, @"C:\Users\BrentK\Documents\Projects\Utilities\yom2013B\zUnitTestsForSolution\bin\Debug\yomBIGGY.s3db"); // _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); // tmp: goto all notes System.Collections.Generic.List<MasterOfLayouts.NameAndGuid> ss = MasterOfLayouts.GetListOfLayouts (""); Assert.AreEqual (3651, ss.Count); //Console.WriteLine(ss.Count); // NewMessage.Show (ss.Count.ToString ()); int count = 0; foreach (MasterOfLayouts.NameAndGuid name in ss) { panel.Dispose (); panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); form.Controls.Add (panel); count++; panel.LoadLayout(name.Guid,false, null); // MDIHOST.DoCloseNote(false); } Assert.AreEqual (3651, count); form.Dispose (); }
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); }
public void TestExistsByName() { //_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("mynewpanel3", true, null); panel.SetName("frank"); NoteDataXML basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); panel.SaveLayout(); Assert.False (MasterOfLayouts.ExistsByName("dasdfasd")); Assert.True (MasterOfLayouts.ExistsByName("frank")); }
public void TestAsterix() { _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"); // 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(0, findBar.PositionsFOUND(), "Found 0 *dogs"); // I removed the code that prevented typing asertixes. Do not remember why I had it. // make sure it does not crash\ }
public void TestReplaceWorks_WithSimiliarWORDS() { //NOTE: This will not work until I implement the Replace system improvements _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 dog 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(5, findBar.PositionsFOUND(), "Found 5 dogs"); findBar.Replace_Text("dog", "dog2"); findBar.DoFind("dog", false,fakeTextNote.GetRichTextBox(),0); Assert.AreEqual(5, findBar.PositionsFOUND(), "Found 5 dogs because we are doing a partial search"); findBar.DoFind("dog", true,fakeTextNote.GetRichTextBox(),0); Assert.AreEqual(0, findBar.PositionsFOUND(), "Found 0 dogs because we are doing an exact search NOTE: This will not work until I implement the Replace system improvements"); findBar.DoFind("dog2", false,fakeTextNote.GetRichTextBox(),0); Assert.AreEqual(5, findBar.PositionsFOUND(), "Found 4 dog2. 4 replacements NOTE: This will not work until I implement the Replace system improvements "); }
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"); }
public void IdentifySubpanels() { // 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"; panelA.GuidForNote = "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 (true,MasterOfLayouts.ExistsByGUID("panela"),"1"); Assert.AreEqual (true,MasterOfLayouts.IsSubpanel("panela"),"2"); Assert.AreEqual (true,MasterOfLayouts.ExistsByGUID("mynewpanel"),"3"); Assert.AreEqual (false,MasterOfLayouts.IsSubpanel("mynewpanel"),"4"); System.Collections.Generic.List<string> children = MasterOfLayouts.GetListOfChildren("mynewpanel"); Assert.AreEqual(1, children.Count); FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel (); panelB.Caption = "PanelB"; panelB.GuidForNote = "panelB"; panel.AddNote (panelB); panelB.CreateParent (panel); panel.SaveLayout (); children = MasterOfLayouts.GetListOfChildren("mynewpanel"); Assert.AreEqual(2, children.Count); Assert.AreEqual ("panela", children[0]); Assert.AreEqual ("panelB", children[1]); }
public void AutosaveThrash() { // just spawna timer and see if I can make it fail _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms .Form form = new System.Windows.Forms.Form(); panelAutosave = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); form.Controls.Add (panelAutosave); // 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 panelname = System.Guid.NewGuid().ToString(); panelAutosave.NewLayout (panelname,true, null); LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel"); _w.output ("herefirst"); Timer SaveTimer= new Timer(); SaveTimer.Interval = 300; SaveTimer.Tick+= HandleSaveTimerTick; SaveTimer.Start (); // ADD 1 of each type foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) { for (int i = 0; i < 2; i++) { NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance (t); panelAutosave.AddNote (note); note.CreateParent(panelAutosave); note.UpdateAfterLoad(); } } panelAutosave.SaveLayout(); // // Second panel // string panelname2 = System.Guid.NewGuid().ToString(); FAKE_LayoutPanel PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); PanelOtherGuy.NewLayout (panelname2,true, null); PanelOtherGuy.SaveLayout(); Assert.AreEqual( 2, PanelOtherGuy.CountNotes(), "count1"); // ADD 1 of each type //foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) { for (int i = 0; i < 10; i++) { NoteDataInterface note = new NoteDataXML_RichText(); PanelOtherGuy.AddNote (note); note.CreateParent(PanelOtherGuy); note.UpdateAfterLoad(); } } Assert.AreEqual( 12, PanelOtherGuy.CountNotes(), "count2"); PanelOtherGuy.SaveLayout(); PanelOtherGuy = null; PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); PanelOtherGuy.LoadLayout(panelname2, false, null); Assert.AreEqual(12, PanelOtherGuy.CountNotes(), "count2"); // add another Layout and do something with it while autosave continues running SaveTimer.Stop(); form.Dispose (); }
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 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 CopyNoteTest() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms .Form form = new System.Windows.Forms.Form(); FAKE_LayoutPanel panelToUse = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); form.Controls.Add (panelToUse); // 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 panelname = System.Guid.NewGuid().ToString(); panelToUse.NewLayout (panelname,true, null); LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel"); _w.output ("herefirst"); Timer SaveTimer= new Timer(); SaveTimer.Interval = 300; SaveTimer.Tick+= HandleSaveTimerTick; SaveTimer.Start (); // ADD 1 of each type foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) { for (int i = 0; i < 2; i++) { NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance (t); panelToUse.AddNote (note); note.CreateParent(panelToUse); note.UpdateAfterLoad(); panelToUse.CopyNote(note); panelToUse.PasteNote(); } } panelToUse.SaveLayout(); //int propercount= 4 * LayoutDetails.Instance.ListOfTypesToStoreInXML().Length; Assert.AreEqual (46, panelToUse.CountNotes()); // // Now we test pasting one of our notes onto another Layout // string panelname2 = System.Guid.NewGuid().ToString(); FAKE_LayoutPanel PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); PanelOtherGuy.NewLayout (panelname2,true, null); PanelOtherGuy.SaveLayout(); form.Controls.Add(PanelOtherGuy); Assert.AreEqual( 2, PanelOtherGuy.CountNotes(), "count1"); // ADD 1 of each type //foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) { for (int i = 0; i < 10; i++) { NoteDataInterface note = new NoteDataXML_RichText(); PanelOtherGuy.AddNote (note); note.CreateParent(PanelOtherGuy); note.UpdateAfterLoad(); } } Assert.AreEqual( 12, PanelOtherGuy.CountNotes(), "count2"); PanelOtherGuy.PasteNote(); Assert.AreEqual( 13, PanelOtherGuy.CountNotes(), "count2"); PanelOtherGuy.SaveLayout(); FAKE_NoteDataXML_Text Noter = new FAKE_NoteDataXML_Text(); Noter.Caption ="Hello there"; PanelOtherGuy.AddNote (Noter); Noter.GetRichTextBox().Text ="bear"; PanelOtherGuy.SaveLayout (); PanelOtherGuy.CopyNote(Noter); NoteDataXML_RichText CopyOfTextNote = (NoteDataXML_RichText)PanelOtherGuy.PasteNote(); Assert.AreEqual ("Hello there",CopyOfTextNote.Caption); Assert.AreEqual ("bear", CopyOfTextNote.GetRichTextBox().Text); // // // Table Copy Test // // NoteDataXML_Table randomTables = new NoteDataXML_Table(100, 100,new ColumnDetails[2]{new ColumnDetails("id",100), new ColumnDetails("tables",100)} ); randomTables.Caption = LayoutDetails.SYSTEM_RANDOM_TABLES; // randomTables.Columns = new appframe.ColumnDetails[2]{new appframe.ColumnDetails("id",100), new appframe.ColumnDetails("tables",100)}; PanelOtherGuy.AddNote(randomTables); //randomTables.CreateParent(PanelOtherGuy); randomTables.AddRow(new object[2]{"1", "example|colors"}); randomTables.AddRow(new object[2]{"2", "example|colorPROMPTS"}); PanelOtherGuy.SaveLayout (); PanelOtherGuy.CopyNote(randomTables); NoteDataXML_Table CopyOfTable = (NoteDataXML_Table)PanelOtherGuy.PasteNote(); Assert.AreEqual (2, CopyOfTable.RowCount()); }
public void CountSizeOfCombinedTableAfterReciprocalLinks() { _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(); // #3 panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); panel.NewLayout("mynewpanel3", true, null); basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); panel.SaveLayout(); note = new NoteDataXML_LinkNote(); panel.AddNote (note); note.CreateParent(panel); note.SetLink("mynewpanel2.thisguid1"); panel.SaveLayout(); Assert.AreEqual(2, Fake_MasterOfLayouts.GetRowCountOfCombinedLinkTableAfterCallToReciprocalLinks()); }
public void InsertRowTest() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); Form form = new 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 panel.NewLayout ("mynewpanel", true, null); FAKE_NoteDataXML_Table test = new FAKE_NoteDataXML_Table (33,0009); test.GuidForNote = "thisguid1"; test.Caption = "note1"; test.CreateParent(panel); test.AddRow(new object[3] {"1", "value1", "testA"}); test.AddRow(new object[3] {"2", "value2", "testB"}); test.AddRow(new object[3] {"3", "value3", "testC"}); panel.SaveLayout (); Assert.AreEqual (3, test.RowCount()); test.GetTablePanel().InsertRow(); Assert.AreEqual (4, test.RowCount()); test.GetTablePanel().InsertRow(); test.GetTablePanel().InsertRow(); Assert.AreEqual (6, test.RowCount()); form.Dispose (); }
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 CountSpecificSubType() { //-- do unit tests counting store 6 textboxes and know this (countbytype) System.Windows.Forms .Form form = new System.Windows.Forms.Form(); _TestSingleTon.Instance._SetupForLayoutPanelTests(); int count = 25; // FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid"); FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); layoutPanel.NewLayout("testguid", true, null); // jan152013 - tweak to allow this to work with new system without rewriting all the tstings in LayoutDatabasetest LayoutDatabase layout = layoutPanel.GetLayoutDatabase(); form.Controls.Add (layoutPanel); form.Show (); NoteDataXML note = new NoteDataXML (); for (int i = 0; i < count; i++) { note.Caption = "boo" + i.ToString (); layout.Add (note); note.CreateParent(layoutPanel); } _w.output (String.Format ("{0} Notes in Layout before save", layout.GetNotes ().Count.ToString ())); for (int i = 0; i < 6; i++) { note = new NoteDataXML_RichText (); note.Caption = "richText"; layout.Add (note); note.CreateParent(layoutPanel); } layout.SaveTo(); // _w.output(String.Format ("{0} Objects Saved", layout.ObjectsSaved().ToString())); layout = new FakeLayoutDatabase ("testguid"); layout.LoadFrom(layoutPanel); // now count RichText notes int count2 = 0; foreach (NoteDataInterface _note in layout.GetNotes ()) { if (_note.GetType() == typeof(NoteDataXML_RichText)) { count2++; } } _w.output(String.Format ("{0} Objects Loaded", layout.GetNotes().Count)); // added linktable Assert.AreEqual (7, count2); }
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 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 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 CountPanelsSubType() { System.Windows.Forms .Form form = new System.Windows.Forms.Form(); _TestSingleTon.Instance._SetupForLayoutPanelTests(); //FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); Assert.False (MasterOfLayouts.ExistsByGUID("testlayout")); _w.output("here"); //-- do unit tests counting store 6 textboxes and know this (countbytype) //_setupforlayoutests (); _w.output("here"); int count = 25; // FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid"); FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); layoutPanel.NewLayout("testlayout", false, null); form.Controls.Add (layoutPanel); form.Show (); NoteDataXML note = new NoteDataXML (); for (int i = 0; i < count; i++) { note.Caption = "boo" + i.ToString (); layoutPanel.AddNote (note); note.CreateParent(layoutPanel); } _w.output (String.Format ("{0} Notes in Layout before save", layoutPanel.GetAllNotes ().Count.ToString ())); for (int i = 0; i < 6; i++) { note = new NoteDataXML_Panel (); note.Caption = "Panel"; layoutPanel.AddNote (note); note.CreateParent(layoutPanel); ((NoteDataXML_Panel)note).Add10TestNotes(); } layoutPanel.SaveLayout(); layoutPanel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); //_w.output(String.Format ("{0} Objects Saved", layoutPanel.ObjectsSaved().ToString())); layoutPanel.LoadLayout("testlayout",false, null); // layout = new FakeLayoutDatabase ("testguid"); // // layout.LoadFrom(layoutPanel); // now count RichText notes int count2 = 0; int subnotecount = 0; foreach (NoteDataInterface _note in layoutPanel.GetAllNotes ()) { if (_note.GetType() == typeof(NoteDataXML_Panel)) { count2++; subnotecount = subnotecount + ((NoteDataXML_Panel)_note).GetChildNotes().Count; } } // total note count should be (once I get GetNotes working on Child Notes = 60 + 6 + 25 = 91 _w.output(String.Format ("{0} Objects Loaded", layoutPanel.GetAllNotes().Count)); //NOT DONE YET Assert.AreEqual (6, count2); Assert.AreEqual (60, subnotecount); Assert.AreEqual (count2, layoutPanel.GetAvailableFolders().Count); // had to change because a linktable makes 91 become 92 Assert.AreEqual (92, layoutPanel.GetAllNotes().Count); }
public void TimelineAndTableAlwaysTogether() { _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); //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) panel.SaveLayout (); Assert.AreEqual (1, panelA.CountNotes (), "Panel A holds one 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 (6, panel.CountNotes (), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); _w.output ("ENDCOUNT"); // add timeline into a PANEL // count 1 row NoteDataXML_Timeline MyTimeLine = new NoteDataXML_Timeline(100,100); MyTimeLine.Caption = "My Timeline!"; panelA.AddNote(MyTimeLine); MyTimeLine.CreateParent(panelA.GetPanelsLayout()); panel.SaveLayout(); // I needed this save else it would not work? Assert.AreEqual (8, panel.CountNotes (), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); string guidOfTimeline = MyTimeLine.GuidForNote; string guidOfTimelineTable = guidOfTimeline + "table"; NoteDataXML_Table FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable); Assert.NotNull(FoundTable); Assert.AreEqual (1, FoundTable.RowCount()); FoundTable = null; // move the TABLE associated with the timeline OUT to parent // count 1 row panelA.myLayoutPanel ().MoveNote(guidOfTimelineTable, "up"); // And for kicks add another timeline just to see if it messages anytnig up NoteDataXML_Timeline MyTimeLine2 = new NoteDataXML_Timeline(100,1020); MyTimeLine2.Caption = "My Timeline! #2"; panel.AddNote(MyTimeLine2); panel.SaveLayout(); Assert.AreEqual (10, panel.CountNotes (), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); Assert.Null(FoundTable); FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable); Assert.NotNull(FoundTable); Assert.AreEqual (1, FoundTable.RowCount()); // move the TABLE into ANOTHER panel // count 1 row _w.output("Moving into panelb now"); panel.MoveNote(guidOfTimelineTable, "panelb"); panel.SaveLayout(); Assert.AreEqual (10, panel.CountNotes (), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); _w.output("done counting"); FoundTable = null; Assert.Null(FoundTable); FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable); Assert.NotNull(FoundTable); Assert.AreEqual (1, FoundTable.RowCount()); form.Dispose (); }