Пример #1
0
        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);
        }