Exemple #1
0
        public void TestAddToSubsetSingle()
        {
            var model    = new MutableModel();
            var factory  = new PropertiesTestFactory(model);
            var base1    = factory.BaseClass();
            var base2    = factory.BaseClass();
            var base3    = factory.BaseClass();
            var base4    = factory.BaseClass();
            var derived1 = factory.DerivedClass();
            var derived2 = factory.DerivedClass();
            var derived3 = factory.DerivedClass();
            var derived4 = factory.DerivedClass();
            var subs     = factory.UnionSingle();

            subs.Subset4 = base1;
            Assert.Equal(base1, subs.Union1);
            Assert.Single(subs.Subset1);
            Assert.Contains(base1, subs.Subset1);
            Assert.Equal(base1, subs.Subset4);
            Assert.Throws <ModelException>(() => subs.Subset1.Add(base2));
            Assert.Equal(base1, subs.Union1);
            Assert.Single(subs.Subset1);
            Assert.Contains(base1, subs.Subset1);
            Assert.Equal(base1, subs.Subset4);
            subs.Subset5 = derived1;
            Assert.Equal(derived1, subs.Union1);
            Assert.Single(subs.Subset1);
            Assert.Contains(derived1, subs.Subset1);
            Assert.Equal(derived1, subs.Subset4);
            Assert.Equal(derived1, subs.Subset5);
            Assert.Throws <ModelException>(() => subs.Subset1.Add(base2));
            subs.Subset5 = derived1;
            Assert.Equal(derived1, subs.Union1);
            Assert.Single(subs.Subset1);
            Assert.Contains(derived1, subs.Subset1);
            Assert.Equal(derived1, subs.Subset4);
            Assert.Equal(derived1, subs.Subset5);
        }