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 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 TestPositionNotChangingWhenItShouldNot() { _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(3, findBar.PositionsFOUND(), "Found 3 dogs"); findBar.GoToNext(); findBar.GoToNext(); Assert.AreEqual(2, findBar.zPosition()); findBar.DoFindBuildLIstTesty(fakeText.Text); Assert.AreEqual(2, findBar.zPosition()); }