コード例 #1
0
        public void IntersectionYieldsImmutableCone()
        {
            ISet mySet = new ListSet(new int[] { 1, 4 });
            ISet clone = Set.Intersect(mySet);

            Assert.IsNotNull(clone);
            Assert.AreEqual(1, clone.Count);
            Assert.Throws <NotSupportedException>(() => clone.Add("bad chair, bad chair"));
        }
コード例 #2
0
        public void Intersect()
        {
            Set.AddAll(UniqueStuff);
            SetForSetOps.AddAll(new object [] { "Bar", StuffOne });
            ISet intersection = Set.Intersect(SetForSetOps);

            Assert.IsTrue(intersection.Count == 1);
            Assert.IsFalse(object.ReferenceEquals(intersection, Set), "Got back same instance after set operation.");
            Assert.IsTrue(Set.Count == UniqueStuff.Length);
            Assert.IsTrue(SetForSetOps.Count == 2);
        }
コード例 #3
0
        public void Intersect()
        {
            ISet actual = Set.Intersect(one, two);

            Assert.IsNotNull(actual);
            Assert.AreEqual(1, actual.Count);
            Assert.IsTrue(actual.Contains(1));
            CheckThatOriginalsHaveNotBeenModified();

            Assert.IsNull(Set.Intersect(null, null));

            actual = Set.Intersect(null, two);
            Assert.AreEqual(0, actual.Count);

            actual = Set.Intersect(one, null);
            Assert.AreEqual(0, actual.Count);
        }