Esempio n. 1
0
        public void CombinedTest()
        {
            var c = new ExtensionCollection();

            Assert.AreEqual(0, c.Count);
            Assert.IsNull(c.Get <ExtensionCollectionTest>());
            AssertEx.ThrowsArgumentException(() => c.Set(typeof(int), 1));
            c.Set(this);
            Assert.AreEqual(1, c.Count);
            Assert.AreSame(this, c.Get <ExtensionCollectionTest>());

            c.Lock();
            AssertEx.Throws <InstanceIsLockedException>(() => c.Set(this));

            var cc = (ExtensionCollection)c.Clone();

            AssertEx.HasSameElements(c, cc);

            var o = new object();

            cc.Set(o);
            Assert.AreEqual(2, cc.Count);
            Assert.AreSame(this, cc.Get <ExtensionCollectionTest>());
            Assert.AreSame(o, cc.Get <object>());
        }