예제 #1
0
        public void T2_Tests()
        {
            IExtensionCollection <GraphObject, IExtension <GraphObject> > exts = _context.Extensions;

            ArborNode node = new ArborNode("");

            exts.Add(node);

            Assert.IsTrue(exts.Contains(node));
            Assert.AreEqual(1, exts.Count);

            IExtension <GraphObject> xt = exts.Find <ArborNode>();

            Assert.IsNotNull(xt);
            Assert.IsTrue(xt is ArborNode);
            Assert.AreEqual(node, xt);

            //

            Assert.IsTrue(exts.Remove(node));
            Assert.IsFalse(exts.Contains(node));
            Assert.AreEqual(0, exts.Count);

            //

            exts.Add(node);
            ArborNode node1 = new ArborNode("");

            exts.Add(node1);

            Assert.IsTrue(exts.Contains(node));
            Assert.IsTrue(exts.Contains(node1));
            Assert.AreEqual(2, exts.Count);

            Collection <ArborNode> cols = exts.FindAll <ArborNode>();

            Assert.AreEqual(2, cols.Count);

            Assert.IsTrue(exts.Remove(node));
            Assert.IsFalse(exts.Contains(node));
            Assert.IsTrue(exts.Contains(node1));
            Assert.AreEqual(1, exts.Count);

            //

            exts.Add(node); // adding second node, but internal array was length=2

            //

            exts.Clear();
            Assert.AreEqual(0, exts.Count);

            //

            Assert.IsFalse(exts.Remove(null));
            Assert.Throws(typeof(ArgumentNullException), () => { exts.Add(null); });
            Assert.Throws(typeof(ArgumentNullException), () => { new ExtensionCollection <GraphObject, IExtension <GraphObject> >(null); });
        }
 bool ICollection <ISerializerExtension> .Remove(ISerializerExtension item) => _extensions.Remove(item);
예제 #3
0
        public bool Remove(IExtension <IOperationContext> item)
        {
            IWrap <IExtension <OperationContext> > wrap = (OperationContextExtensionWrap)item;

            return(UnderlyingObject.Remove(wrap.UnderlyingObject));
        }