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)); }
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 })); }
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() })); }
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", "" })); }
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)); }
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); }
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>()); }
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>()); }
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); }
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); }
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() })); }
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)); }
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>()); }
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>()); }
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)); }
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 })); }
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); }