public void SetOfTwo() {
            var projectEntry = CreateProjectEntry();
            var value1 = new TestAnalysisValue(projectEntry);
            var value2 = new TestAnalysisValue(projectEntry);

            TestImmutableSet(new AnalysisSetTwoObject(value1.Proxy, value2.Proxy));
        }
        public void WrapperSelfSet() {
            var projectEntry = CreateProjectEntry();
            var value = new TestAnalysisValue(projectEntry);

            Assert.IsTrue(((IAnalysisSet)value.Proxy).Contains(value.Proxy));
            TestImmutableSet(value.Proxy);
        }
Example #3
0
        public void SetOfOne()
        {
            var projectEntry = CreateProjectEntry();
            var value        = new TestAnalysisValue(projectEntry);

            TestImmutableSet(value.Proxy);
        }
Example #4
0
        public void Set_TypeSplit()
        {
            IReadOnlyList <SubTestAnalysisValue> ofType;
            IAnalysisSet rest;

            var testAv = new TestAnalysisValue {
                _name = "A", Value = "A"
            };
            var subTestAv = new SubTestAnalysisValue {
                _name = "B", Value = "B"
            };

            Assert.IsTrue(subTestAv.Split(out ofType, out rest));
            Assert.AreEqual(1, ofType.Count);
            Assert.AreSame(subTestAv, ofType[0]);
            Assert.AreEqual(0, rest.Count);

            Assert.IsFalse(testAv.Split(out ofType, out rest));
            Assert.AreEqual(0, ofType.Count);
            Assert.AreSame(testAv, rest);

            var set = AnalysisSet.Create(new[] { testAv, subTestAv });

            Assert.IsTrue(set.Split(out ofType, out rest));
            Assert.AreEqual(1, ofType.Count);
            Assert.AreSame(testAv, rest);

            set = AnalysisSet.Create(new[] { nsA1, nsB1, nsC1 });
            Assert.IsFalse(set.Split(out ofType, out rest));
            Assert.AreEqual(0, ofType.Count);
            Assert.AreSame(set, rest);
        }
        public void Set_TypeSplit()
        {
            var testAv = new TestAnalysisValue {
                _name = "A", Value = "A"
            };
            var subTestAv = new SubTestAnalysisValue {
                _name = "B", Value = "B"
            };

            subTestAv.Split(out IReadOnlyList <SubTestAnalysisValue> ofType, out var rest).Should().BeTrue();
            ofType.Should().ContainSingle().Which.Should().BeSameAs(subTestAv);
            rest.Should().BeEmpty();

            testAv.Split(out ofType, out rest).Should().BeFalse();
            ofType.Should().BeEmpty();
            rest.Should().BeSameAs(testAv);

            var set = AnalysisSet.Create(new[] { testAv, subTestAv });

            set.Split(out ofType, out rest).Should().BeTrue();
            ofType.Should().ContainSingle();
            rest.Should().BeSameAs(testAv);

            set = AnalysisSet.Create(new[] { nsA1, nsB1, nsC1 });
            set.Split(out ofType, out rest).Should().BeFalse();
            ofType.Should().BeEmpty();
            rest.Should().BeSameAs(set);
        }
Example #6
0
        public void SetOfTwo()
        {
            var projectEntry = CreateProjectEntry();
            var value1       = new TestAnalysisValue(projectEntry);
            var value2       = new TestAnalysisValue(projectEntry);

            TestImmutableSet(new AnalysisSetTwoObject(value1.Proxy, value2.Proxy));
        }
Example #7
0
        public void WrapperSelfSet()
        {
            var projectEntry = CreateProjectEntry();
            var value        = new TestAnalysisValue(projectEntry);

            Assert.IsTrue(((IAnalysisSet)value.Proxy).Contains(value.Proxy));
            TestImmutableSet(value.Proxy);
        }
Example #8
0
        private static void TestImmutableSet(IAnalysisSet emptySet)
        {
            int count = emptySet.Count;

            var projectEntry = CreateProjectEntry();
            var value        = new TestAnalysisValue(projectEntry);

            var newSet = emptySet.Add(value.Proxy);

            Assert.AreNotEqual(emptySet, newSet);
            Assert.AreEqual(count, emptySet.Count);
            Assert.AreEqual(count + 1, newSet.Count);

            bool wasChanged;

            newSet = emptySet.Add(value.Proxy, out wasChanged);
            Assert.AreNotEqual(emptySet, newSet);
            Assert.IsTrue(wasChanged);
            Assert.AreEqual(count, emptySet.Count);
            Assert.AreEqual(count + 1, newSet.Count);

            newSet = emptySet.Union(new[] { value.Proxy });
            Assert.AreNotEqual(emptySet, newSet);
            Assert.AreEqual(count, emptySet.Count);
            Assert.AreEqual(count + 1, newSet.Count);

            newSet = emptySet.Union(new[] { value.Proxy }, out wasChanged);
            Assert.IsTrue(wasChanged);
            Assert.AreNotEqual(emptySet, newSet);
            Assert.AreEqual(count, emptySet.Count);
            Assert.AreEqual(count + 1, newSet.Count);

            Assert.AreEqual(emptySet, emptySet.Clone());

            Assert.IsFalse(emptySet.Contains(value.Proxy));
        }
 public void SetOfOne() {
     var projectEntry = CreateProjectEntry();
     var value = new TestAnalysisValue(projectEntry);
     
     TestImmutableSet(value.Proxy);
 }
        private static void TestImmutableSet(IAnalysisSet emptySet) {
            int count = emptySet.Count;

            var projectEntry = CreateProjectEntry();
            var value = new TestAnalysisValue(projectEntry);

            var newSet = emptySet.Add(value.Proxy);
            Assert.AreNotEqual(emptySet, newSet);
            Assert.AreEqual(count, emptySet.Count);
            Assert.AreEqual(count + 1, newSet.Count);

            bool wasChanged;
            newSet = emptySet.Add(value.Proxy, out wasChanged);
            Assert.AreNotEqual(emptySet, newSet);
            Assert.IsTrue(wasChanged);
            Assert.AreEqual(count, emptySet.Count);
            Assert.AreEqual(count + 1, newSet.Count);

            newSet = emptySet.Union(new[] { value.Proxy });
            Assert.AreNotEqual(emptySet, newSet);
            Assert.AreEqual(count, emptySet.Count);
            Assert.AreEqual(count + 1, newSet.Count);

            newSet = emptySet.Union(new[] { value.Proxy }, out wasChanged);
            Assert.IsTrue(wasChanged);
            Assert.AreNotEqual(emptySet, newSet);
            Assert.AreEqual(count, emptySet.Count);
            Assert.AreEqual(count + 1, newSet.Count);

            Assert.AreEqual(emptySet, emptySet.Clone());

            Assert.IsFalse(emptySet.Contains(value.Proxy));
        }