コード例 #1
0
        public void Merge_NullOrEmptyString_Throws()
        {
            var collection = new ServiceNameCollection(new[] { "first", "second" });

            Assert.Throws <ArgumentException>(() => collection.Merge((string)null));
            Assert.Throws <ArgumentException>(() => collection.Merge(string.Empty));
        }
コード例 #2
0
        public void Merge_EnumerableContainingNullOrEmpty_Throws(string item)
        {
            var collection = new ServiceNameCollection(new[] { "first", "second" });

            Assert.Throws <ArgumentException>(() => collection.Merge(new[] { item }));
            Assert.Throws <ArgumentException>(() => collection.Merge(new[] { "third", item }));
        }
コード例 #3
0
        public void Merge_NonStringEnumerable_Throws()
        {
            var collection = new ServiceNameCollection(new[] { "first", "second" });

            Assert.Throws <ArgumentException>(() => collection.Merge(new[] { 3 }));
            Assert.Throws <ArgumentException>(() => collection.Merge(new[] { new object() }));
        }
コード例 #4
0
        public void Merge_EnumerableContainingNullOrEmpty_Throws()
        {
            var collection = new ServiceNameCollection(new[] { "first", "second" });

            AssertExtensions.Throws <ArgumentNullException>("serviceName", () => collection.Merge(new[] { (string)null }));
            AssertExtensions.Throws <ArgumentNullException>("serviceName", () => collection.Merge(new[] { "third", null }));
            AssertExtensions.Throws <ArgumentException>("serviceName", () => collection.Merge(new[] { "" }));
            AssertExtensions.Throws <ArgumentException>("serviceName", () => collection.Merge(new[] { "third", "" }));
        }
コード例 #5
0
        public void Merge_NullEnumerable_Throws()
        {
            var collection = new ServiceNameCollection(new[] { "first", "second" });

            // This really should be ArgumentNullException, but the full framework does not
            // guard against null, so NullReferenceException ends up being thrown instead.
            Assert.Throws <NullReferenceException>(() => collection.Merge((IEnumerable)null));
        }
コード例 #6
0
        public void Merge_VariousEnumerables_Success(string[] expected, IEnumerable serviceNames)
        {
            var collection = new ServiceNameCollection(new[] { "first", "second" });
            ServiceNameCollection merged = collection.Merge(serviceNames);

            Assert.Equal(expected, merged.Cast <string>());
            Assert.Equal(expected.Length, merged.Count);
        }
コード例 #7
0
        public void Merge_NonDuplicateString_Succeeds()
        {
            string[] expected   = new[] { "first", "second", "third" };
            var      collection = new ServiceNameCollection(new[] { "first", "second" });

            ServiceNameCollection merged = collection.Merge("third");

            Assert.Equal(expected, merged.Cast <string>());
        }
コード例 #8
0
        public void Merge_DuplicateString_DuplicateFiltered(string duplicate)
        {
            string[] expected   = new[] { "first", "second" };
            var      collection = new ServiceNameCollection(new[] { "first", "second" });

            ServiceNameCollection merged = collection.Merge(duplicate);

            Assert.Equal(expected, merged.Cast <string>());
        }
コード例 #9
0
 public static bool IsSubset(ServiceNameCollection primaryList, ServiceNameCollection subset)
 {
     if ((subset == null) || (subset.Count == 0))
     {
         return(true);
     }
     if ((primaryList == null) || (primaryList.Count < subset.Count))
     {
         return(false);
     }
     return(primaryList.Merge(subset).Count == primaryList.Count);
 }
コード例 #10
0
        public static bool IsSubset(ServiceNameCollection primaryList, ServiceNameCollection subset)
        {
            bool result = false;

            if (subset == null || subset.Count == 0)
            {
                result = true;
            }
            else if (primaryList == null || primaryList.Count < subset.Count)
            {
                result = false;
            }
            else
            {
                ServiceNameCollection merged = primaryList.Merge(subset);

                //The merge routine only adds an entry if it is unique.
                result = (merged.Count == primaryList.Count);
            }

            return(result);
        }
コード例 #11
0
 public void Merge_NonStringEnumerable_Throws()
 {
     var collection = new ServiceNameCollection(new[] { "first", "second" });
     Assert.Throws<ArgumentException>(() => collection.Merge(new[] { 3 }));
     Assert.Throws<ArgumentException>(() => collection.Merge(new[] { new object() }));
 }
コード例 #12
0
 public void Merge_NullOrEmptyString_Throws()
 {
     var collection = new ServiceNameCollection(new[] { "first", "second" });
     Assert.Throws<ArgumentException>(() => collection.Merge((string)null));
     Assert.Throws<ArgumentException>(() => collection.Merge(string.Empty));
 }
コード例 #13
0
        public void Merge_NonDuplicateString_Succeeds()
        {
            string[] expected = new[] { "first", "second", "third" };
            var collection = new ServiceNameCollection(new[] { "first", "second" });

            ServiceNameCollection merged = collection.Merge("third");
            Assert.Equal(expected, merged.Cast<string>());
        }
コード例 #14
0
        public void Merge_DuplicateString_DuplicateFiltered(string duplicate)
        {
            string[] expected = new[] { "first", "second" };
            var collection = new ServiceNameCollection(new[] { "first", "second" });

            ServiceNameCollection merged = collection.Merge(duplicate);
            Assert.Equal(expected, merged.Cast<string>());
        }
コード例 #15
0
        public void Merge_NullEnumerable_Throws()
        {
            var collection = new ServiceNameCollection(new[] { "first", "second" });

            // This really should be ArgumentNullException, but the full framework does not
            // guard against null, so NullReferenceException ends up being thrown instead.
            Assert.Throws<NullReferenceException>(() => collection.Merge((IEnumerable)null));
        }
コード例 #16
0
 public void Merge_EnumerableContainingNullOrEmpty_Throws(string item)
 {
     var collection = new ServiceNameCollection(new[] { "first", "second" });
     Assert.Throws<ArgumentException>(() => collection.Merge(new[] { item }));
     Assert.Throws<ArgumentException>(() => collection.Merge(new[] { "third", item }));
 }
コード例 #17
0
 public void Merge_VariousEnumerables_Success(string[] expected, IEnumerable serviceNames)
 {
     var collection = new ServiceNameCollection(new[] { "first", "second" });
     ServiceNameCollection merged = collection.Merge(serviceNames);
     Assert.Equal(expected, merged.Cast<string>());
     Assert.Equal(expected.Length, merged.Count);
 }