コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();

            var tc = new TagCollection();
            tc.Add("one", 1);
            tc.Add("one", 2);

            var tc2 = new TagCollection();
            tc2.AddOrUpdateFrom(tc);
            tc2.AddOrUpdateFrom(tc);

            int a = 1;
        }
コード例 #2
0
        public void All_items_added__existing_items_removed()
        {
            ITagCollection tc = new TagCollection();
            tc.Add("one", 1);
            tc.Add("one", 2);
            tc.Add("one", 3);

            tc.Add("two", 11);
            tc.Add("two", 12);

            ITagCollection tc2 = new TagCollection();
            tc2.Add("one", 0);
            tc2.Add("one", 1);

            tc2.AddOrUpdateFrom(tc, overrideOldValues: true);

            var vals = tc2["one"];

            Assert.AreEqual(3, vals.Count);
            Assert.IsTrue(vals.Contains(1));
            Assert.IsTrue(vals.Contains(2));
            Assert.IsTrue(vals.Contains(3));

            vals = tc2["two"];

            Assert.AreEqual(2, vals.Count);
            Assert.IsTrue(vals.Contains(11));
            Assert.IsTrue(vals.Contains(12));

            Assert.AreEqual(5, tc2.Count());
        }
コード例 #3
0
        public void All_items_added__By_default_existing_items_remain_unchanged()
        {
            ITagCollection tc = new TagCollection();
            tc.Add("one", 1);
            tc.Add("one", 2);
            tc.Add("one", 3);

            tc.Add("two", 11);
            tc.Add("two", 12);

            ITagCollection tc2 = new TagCollection();
            tc2.Add("one", 0);
            tc2.Add("one", 1);

            tc2.AddOrUpdateFrom(tc);

            var vals = tc2["one"];

            Assert.AreEqual(4, vals.Count);
            Assert.IsTrue(vals.Contains(0));
            Assert.IsTrue(vals.Contains(1));
            Assert.IsTrue(vals.Contains(2));
            Assert.IsTrue(vals.Contains(3));


            vals = tc2["two"];

            Assert.AreEqual(2, vals.Count);
            Assert.IsTrue(vals.Contains(11));
            Assert.IsTrue(vals.Contains(12));

            Assert.AreEqual(6, tc2.Count());
        }