コード例 #1
0
        public void ShouldBeAbleToRemoveAnElementFromImmutableCollection()
        {
            var elements = new List <string> {
                "Element1", "Element2"
            };
            IImmutableCollection <String> immutableCollection    = new ImmutableCollection <String>(elements);
            IImmutableCollection <String> newImmutableCollection = immutableCollection.Remove("Element1");

            Assert.Equals(2, immutableCollection.Size());
            Assert.Equals(1, newImmutableCollection.Size());
        }
コード例 #2
0
        public void ShouldAddNewElementToImmutableCollection()
        {
            var elements = new List <string> {
                "Element1", "Element2"
            };
            IImmutableCollection <String> immutableCollection    = new ImmutableCollection <String>(elements);
            IImmutableCollection <String> newImmutableCollection = immutableCollection.Add("newElement");

            Assert.Equals(2, immutableCollection.Size());
            Assert.Equals(3, newImmutableCollection.Size());
        }