Exemple #1
0
        public void MergeTwoSubsets()
        {
            RelayTwo relay = new RelayTwo();

            TableTwo table = relay.CreateTable("Table1");

            table.AddField <string>("name");
            table.AddField <bool>("1337");

            TableRow row1 = table.CreateRow();
            TableRow row2 = table.CreateRow();
            TableRow row3 = table.CreateRow();

            row1.Set("name", "Arne");
            row1.Set("1337", false);

            row2.Set("name", "Björn");
            row2.Set("1337", true);

            row3.Set("name", "Charlie");
            row3.Set("1337", false);

            Assert.AreEqual(3, table.GetRows().Length);

            RelayTwo subsetA = relay.Subset("Table1", (o => o.Get <bool>("1337") == true));
            RelayTwo subsetB = relay.Subset("Table1", (o => o.Get <bool>("1337") == false));

            subsetA.MergeWith(subsetB);
            Assert.Throws <RelayTwo.RelayMergeException>(() => subsetB.MergeWith(relay));
            Assert.AreEqual(true, subsetA.Equals(relay));
            Assert.AreEqual(false, subsetB.Equals(relay));
        }