diff options
author | Daniel Harvey <dharvey@microsoft.com> | 2017-04-18 19:52:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-18 19:52:02 +0300 |
commit | b43b4df2e0e2182154bb0f425cb4a61bc1269828 (patch) | |
tree | 0542a70918ed2276e68091b6ec724e09e040c1de /src/System.Linq | |
parent | f61b464b62939e8ab8361d41a78ecf21304a42ed (diff) |
Bulk updates of tests for AssertExtensions (#18491)
Bulk update to AssertExtensions.Throws for AOT support. This doesn't disable Assert.Throws.
Diffstat (limited to 'src/System.Linq')
53 files changed, 343 insertions, 339 deletions
diff --git a/src/System.Linq/tests/AggregateTests.cs b/src/System.Linq/tests/AggregateTests.cs index 5d6d5873c0..3c663e0dc4 100644 --- a/src/System.Linq/tests/AggregateTests.cs +++ b/src/System.Linq/tests/AggregateTests.cs @@ -186,25 +186,25 @@ namespace System.Linq.Tests [Fact] public void NullSource() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate((x, y) => x + y)); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate(0, (x, y) => x + y)); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate(0, (x, y) => x + y, i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate((x, y) => x + y)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate(0, (x, y) => x + y)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate(0, (x, y) => x + y, i => i)); } [Fact] public void NullFunc() { Func<int, int, int> func = null; - Assert.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(func)); - Assert.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(0, func)); - Assert.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(0, func, i => i)); + AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(func)); + AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(0, func)); + AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(0, func, i => i)); } [Fact] public void NullResultSelector() { Func<int, int> resultSelector = null; - Assert.Throws<ArgumentNullException>("resultSelector", () => Enumerable.Range(0, 3).Aggregate(0, (x, y) => x + y, resultSelector)); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => Enumerable.Range(0, 3).Aggregate(0, (x, y) => x + y, resultSelector)); } } } diff --git a/src/System.Linq/tests/AllTests.cs b/src/System.Linq/tests/AllTests.cs index 4c1f069bfc..54a0e673c5 100644 --- a/src/System.Linq/tests/AllTests.cs +++ b/src/System.Linq/tests/AllTests.cs @@ -66,14 +66,14 @@ namespace System.Linq.Tests [Fact] public void NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).All(i => i != 0)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).All(i => i != 0)); } [Fact] public void NullPredicate_ThrowsArgumentNullException() { Func<int, bool> predicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).All(predicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).All(predicate)); } } } diff --git a/src/System.Linq/tests/AnyTests.cs b/src/System.Linq/tests/AnyTests.cs index 9355ba83ab..9337da19f2 100644 --- a/src/System.Linq/tests/AnyTests.cs +++ b/src/System.Linq/tests/AnyTests.cs @@ -88,15 +88,15 @@ namespace System.Linq.Tests [Fact] public void NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Any()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Any(i => i != 0)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Any()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Any(i => i != 0)); } [Fact] public void NullPredicate_ThrowsArgumentNullException() { Func<int, bool> predicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Any(predicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Any(predicate)); } } } diff --git a/src/System.Linq/tests/AppendPrependTests.cs b/src/System.Linq/tests/AppendPrependTests.cs index d701fe3af9..b39bc70645 100644 --- a/src/System.Linq/tests/AppendPrependTests.cs +++ b/src/System.Linq/tests/AppendPrependTests.cs @@ -114,8 +114,8 @@ namespace System.Linq.Tests [Fact] public void SourceNull() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Append(1)); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Prepend(1)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Append(1)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Prepend(1)); } [Fact] diff --git a/src/System.Linq/tests/AverageTests.cs b/src/System.Linq/tests/AverageTests.cs index 4d84492581..630bea11aa 100644 --- a/src/System.Linq/tests/AverageTests.cs +++ b/src/System.Linq/tests/AverageTests.cs @@ -58,15 +58,15 @@ namespace System.Linq.Tests [Fact] public void NullableFloat_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Average(i => i)); } [Fact] public void NullableFloat_NullSelector_ThrowsArgumentNullException() { Func<float?, float?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float?>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float?>().Average(selector)); } [Fact] @@ -95,15 +95,15 @@ namespace System.Linq.Tests [Fact] public void Int_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Average(i => i)); } [Fact] public void Int_NullSelector_ThrowsArgumentNullException() { Func<int, int> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int>().Average(selector)); } public static IEnumerable<object[]> Int_TestData() @@ -163,15 +163,15 @@ namespace System.Linq.Tests [Fact] public void NullableInt_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Average(i => i)); } [Fact] public void NullableInt_NullSelector_ThrowsArgumentNullException() { Func<int?, int?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int?>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int?>().Average(selector)); } [Fact] @@ -200,15 +200,15 @@ namespace System.Linq.Tests [Fact] public void Long_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Average(i => i)); } [Fact] public void Long_NullSelector_ThrowsArgumentNullException() { Func<long, long> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long>().Average(selector)); } public static IEnumerable<object[]> Long_TestData() @@ -269,15 +269,15 @@ namespace System.Linq.Tests [Fact] public void NullableLong_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Average(i => i)); } [Fact] public void NullableLong_NullSelector_ThrowsArgumentNullException() { Func<long?, long?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long?>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long?>().Average(selector)); } [Fact] @@ -306,15 +306,15 @@ namespace System.Linq.Tests [Fact] public void Double_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Average(i => i)); } [Fact] public void Double_NullSelector_ThrowsArgumentNullException() { Func<double, double> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double>().Average(selector)); } public static IEnumerable<object[]> Double_TestData() @@ -369,15 +369,15 @@ namespace System.Linq.Tests [Fact] public void NullableDouble_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Average(i => i)); } [Fact] public void NullableDouble_NullSelector_ThrowsArgumentNullException() { Func<double?, double?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double?>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double?>().Average(selector)); } [Fact] @@ -406,15 +406,15 @@ namespace System.Linq.Tests [Fact] public void Decimal_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Average(i => i)); } [Fact] public void Decimal_NullSelector_ThrowsArgumentNullException() { Func<decimal, decimal> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal>().Average(selector)); } public static IEnumerable<object[]> Decimal_TestData() @@ -467,15 +467,15 @@ namespace System.Linq.Tests [Fact] public void NullableDecimal_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Average(i => i)); } [Fact] public void NullableDecimal_NullSelector_ThrowsArgumentNullException() { Func<decimal?, decimal?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal?>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal?>().Average(selector)); } [Fact] @@ -512,15 +512,15 @@ namespace System.Linq.Tests [Fact] public void Float_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Average()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Average(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Average()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Average(i => i)); } [Fact] public void Float_NullSelector_ThrowsArgumentNullException() { Func<float, float> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float>().Average(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float>().Average(selector)); } public static IEnumerable<object[]> Float_TestData() diff --git a/src/System.Linq/tests/CastTests.cs b/src/System.Linq/tests/CastTests.cs index 0d74305956..7606c31290 100644 --- a/src/System.Linq/tests/CastTests.cs +++ b/src/System.Linq/tests/CastTests.cs @@ -225,7 +225,7 @@ namespace System.Linq.Tests [Fact] public void NullSource() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<object>)null).Cast<string>()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<object>)null).Cast<string>()); } [Fact] diff --git a/src/System.Linq/tests/ConcatTests.cs b/src/System.Linq/tests/ConcatTests.cs index 68394debe7..1d5e99697a 100644 --- a/src/System.Linq/tests/ConcatTests.cs +++ b/src/System.Linq/tests/ConcatTests.cs @@ -58,14 +58,14 @@ namespace System.Linq.Tests [Fact] public void FirstNull() { - Assert.Throws<ArgumentNullException>("first", () => ((IEnumerable<int>)null).Concat(Enumerable.Range(0, 0))); - Assert.Throws<ArgumentNullException>("first", () => ((IEnumerable<int>)null).Concat(null)); // If both inputs are null, throw for "first" first + AssertExtensions.Throws<ArgumentNullException>("first", () => ((IEnumerable<int>)null).Concat(Enumerable.Range(0, 0))); + AssertExtensions.Throws<ArgumentNullException>("first", () => ((IEnumerable<int>)null).Concat(null)); // If both inputs are null, throw for "first" first } [Fact] public void SecondNull() { - Assert.Throws<ArgumentNullException>("second", () => Enumerable.Range(0, 0).Concat(null)); + AssertExtensions.Throws<ArgumentNullException>("second", () => Enumerable.Range(0, 0).Concat(null)); } [Theory] diff --git a/src/System.Linq/tests/ContainsTests.cs b/src/System.Linq/tests/ContainsTests.cs index 7473136045..1ae6ce88e6 100644 --- a/src/System.Linq/tests/ContainsTests.cs +++ b/src/System.Linq/tests/ContainsTests.cs @@ -111,8 +111,8 @@ namespace System.Linq.Tests { IEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.Contains(42)); - Assert.Throws<ArgumentNullException>("source", () => source.Contains(42, EqualityComparer<int>.Default)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Contains(42)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Contains(42, EqualityComparer<int>.Default)); } [Fact] diff --git a/src/System.Linq/tests/CountTests.cs b/src/System.Linq/tests/CountTests.cs index dc402c0dfd..ae1f8918bc 100644 --- a/src/System.Linq/tests/CountTests.cs +++ b/src/System.Linq/tests/CountTests.cs @@ -119,15 +119,15 @@ namespace System.Linq.Tests [Fact] public void NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Count()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Count(i => i != 0)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Count()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Count(i => i != 0)); } [Fact] public void NullPredicate_ThrowsArgumentNullException() { Func<int, bool> predicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Count(predicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Count(predicate)); } } } diff --git a/src/System.Linq/tests/DefaultIfEmptyTests.cs b/src/System.Linq/tests/DefaultIfEmptyTests.cs index b3fd7c9685..87f582dd0f 100644 --- a/src/System.Linq/tests/DefaultIfEmptyTests.cs +++ b/src/System.Linq/tests/DefaultIfEmptyTests.cs @@ -94,8 +94,8 @@ namespace System.Linq.Tests { IEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.DefaultIfEmpty()); - Assert.Throws<ArgumentNullException>("source", () => source.DefaultIfEmpty(42)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.DefaultIfEmpty()); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.DefaultIfEmpty(42)); } [Fact] diff --git a/src/System.Linq/tests/DistinctTests.cs b/src/System.Linq/tests/DistinctTests.cs index 47a8bdbf4f..de7863f21a 100644 --- a/src/System.Linq/tests/DistinctTests.cs +++ b/src/System.Linq/tests/DistinctTests.cs @@ -149,7 +149,7 @@ namespace System.Linq.Tests { string[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.Distinct()); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Distinct()); } [Fact] @@ -157,7 +157,7 @@ namespace System.Linq.Tests { string[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.Distinct(StringComparer.Ordinal)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Distinct(StringComparer.Ordinal)); } [Fact] diff --git a/src/System.Linq/tests/ElementAtOrDefaultTests.cs b/src/System.Linq/tests/ElementAtOrDefaultTests.cs index 697b4c64b7..8d374f3234 100644 --- a/src/System.Linq/tests/ElementAtOrDefaultTests.cs +++ b/src/System.Linq/tests/ElementAtOrDefaultTests.cs @@ -78,7 +78,7 @@ namespace System.Linq.Tests [Fact] public void NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).ElementAtOrDefault(2)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).ElementAtOrDefault(2)); } } } diff --git a/src/System.Linq/tests/ElementAtTests.cs b/src/System.Linq/tests/ElementAtTests.cs index c2421d0842..7868a029fd 100644 --- a/src/System.Linq/tests/ElementAtTests.cs +++ b/src/System.Linq/tests/ElementAtTests.cs @@ -56,13 +56,13 @@ namespace System.Linq.Tests [Fact] public void InvalidIndex_ThrowsArgumentOutOfRangeException() { - Assert.Throws<ArgumentOutOfRangeException>("index", () => new int?[] { 9, 8 }.ElementAt(-1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => new int[] { 1, 2, 3, 4 }.ElementAt(4)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => new int[0].ElementAt(0)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => new int?[] { 9, 8 }.ElementAt(-1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => new int[] { 1, 2, 3, 4 }.ElementAt(4)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => new int[0].ElementAt(0)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(-4, 5).ElementAt(-1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(5, 5).ElementAt(5)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(0, 0).ElementAt(0)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(-4, 5).ElementAt(-1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(5, 5).ElementAt(5)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(0, 0).ElementAt(0)); } @@ -78,7 +78,7 @@ namespace System.Linq.Tests [Fact] public void NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).ElementAt(2)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).ElementAt(2)); } } } diff --git a/src/System.Linq/tests/EmptyPartitionTests.cs b/src/System.Linq/tests/EmptyPartitionTests.cs index 1559fe7299..4553e57da0 100644 --- a/src/System.Linq/tests/EmptyPartitionTests.cs +++ b/src/System.Linq/tests/EmptyPartitionTests.cs @@ -51,7 +51,7 @@ namespace System.Linq.Tests [Fact] public void ElementAtThrows() { - Assert.Throws<ArgumentOutOfRangeException>("index", () => GetEmptyPartition<int>().ElementAt(0)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => GetEmptyPartition<int>().ElementAt(0)); } [Fact] diff --git a/src/System.Linq/tests/ExceptTests.cs b/src/System.Linq/tests/ExceptTests.cs index 7711c0bbb4..814cd9aad2 100644 --- a/src/System.Linq/tests/ExceptTests.cs +++ b/src/System.Linq/tests/ExceptTests.cs @@ -103,8 +103,8 @@ namespace System.Linq.Tests string[] first = null; string[] second = { "bBo", "shriC" }; - Assert.Throws<ArgumentNullException>("first", () => first.Except(second)); - Assert.Throws<ArgumentNullException>("first", () => first.Except(second, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("first", () => first.Except(second)); + AssertExtensions.Throws<ArgumentNullException>("first", () => first.Except(second, new AnagramEqualityComparer())); } [Fact] @@ -113,8 +113,8 @@ namespace System.Linq.Tests string[] first = { "Bob", "Tim", "Robert", "Chris" }; string[] second = null; - Assert.Throws<ArgumentNullException>("second", () => first.Except(second)); - Assert.Throws<ArgumentNullException>("second", () => first.Except(second, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("second", () => first.Except(second)); + AssertExtensions.Throws<ArgumentNullException>("second", () => first.Except(second, new AnagramEqualityComparer())); } [Fact] diff --git a/src/System.Linq/tests/FirstOrDefaultTests.cs b/src/System.Linq/tests/FirstOrDefaultTests.cs index e8aa5f9b61..e4e5927233 100644 --- a/src/System.Linq/tests/FirstOrDefaultTests.cs +++ b/src/System.Linq/tests/FirstOrDefaultTests.cs @@ -190,20 +190,20 @@ namespace System.Linq.Tests [Fact] public void NullSource() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).FirstOrDefault()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).FirstOrDefault()); } [Fact] public void NullSourcePredicateUsed() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).FirstOrDefault(i => i != 2)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).FirstOrDefault(i => i != 2)); } [Fact] public void NullPredicate() { Func<int, bool> predicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).FirstOrDefault(predicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).FirstOrDefault(predicate)); } } } diff --git a/src/System.Linq/tests/FirstTests.cs b/src/System.Linq/tests/FirstTests.cs index 4ec47d0325..fed8b1f6ca 100644 --- a/src/System.Linq/tests/FirstTests.cs +++ b/src/System.Linq/tests/FirstTests.cs @@ -187,20 +187,20 @@ namespace System.Linq.Tests [Fact] public void NullSource() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).First()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).First()); } [Fact] public void NullSourcePredicateUsed() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).First(i => i != 2)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).First(i => i != 2)); } [Fact] public void NullPredicate() { Func<int, bool> predicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).First(predicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).First(predicate)); } } } diff --git a/src/System.Linq/tests/GroupByTests.cs b/src/System.Linq/tests/GroupByTests.cs index 6a218eb6c5..be12a60b0e 100644 --- a/src/System.Linq/tests/GroupByTests.cs +++ b/src/System.Linq/tests/GroupByTests.cs @@ -147,8 +147,8 @@ namespace System.Linq.Tests Assert.True(e.MoveNext()); IList<int> odds = (IList<int>)e.Current; - Assert.Throws<ArgumentOutOfRangeException>("index", () => odds[-1]); - Assert.Throws<ArgumentOutOfRangeException>("index", () => odds[23]); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => odds[-1]); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => odds[23]); } [Fact] @@ -224,29 +224,29 @@ namespace System.Linq.Tests public void SourceIsNull() { Record[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, e => e.Score, new AnagramEqualityComparer())); - Assert.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, e => e.Score, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, new AnagramEqualityComparer())); } [Fact] public void SourceIsNullResultSelectorUsed() { Record[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, e => e.Score, (k, es) => es.Sum(), new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, e => e.Score, (k, es) => es.Sum(), new AnagramEqualityComparer())); } [Fact] public void SourceIsNullResultSelectorUsedNoComparer() { Record[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, e => e.Score, (k, es) => es.Sum())); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, e => e.Score, (k, es) => es.Sum())); } [Fact] public void SourceIsNullResultSelectorUsedNoComparerOrElementSelector() { Record[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, (k, es) => es.Sum(e => e.Score))); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.GroupBy(e => e.Name, (k, es) => es.Sum(e => e.Score))); } [Fact] @@ -262,8 +262,8 @@ namespace System.Linq.Tests new Record { Name = "Tim", Score = 25 } }; - Assert.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(null, e => e.Score, new AnagramEqualityComparer())); - Assert.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(null, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(null, e => e.Score, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(null, new AnagramEqualityComparer())); } [Fact] @@ -279,7 +279,7 @@ namespace System.Linq.Tests new Record { Name = "Tim", Score = 25 } }; - Assert.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(null, e => e.Score, (k, es) => es.Sum(), new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(null, e => e.Score, (k, es) => es.Sum(), new AnagramEqualityComparer())); } [Fact] @@ -297,7 +297,7 @@ namespace System.Linq.Tests Func<Record, string> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(keySelector, e => e.Score, (k, es) => es.Sum())); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(keySelector, e => e.Score, (k, es) => es.Sum())); } [Fact] @@ -307,7 +307,7 @@ namespace System.Linq.Tests int[] element = { 60, -10, 40, 100 }; var source = key.Zip(element, (k, e) => new Record { Name = k, Score = e }); - Assert.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(null, (k, es) => es.Sum(e => e.Score), new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => source.GroupBy(null, (k, es) => es.Sum(e => e.Score), new AnagramEqualityComparer())); } [Fact] @@ -325,7 +325,7 @@ namespace System.Linq.Tests Func<Record, int> elementSelector = null; - Assert.Throws<ArgumentNullException>("elementSelector", () => source.GroupBy(e => e.Name, elementSelector, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => source.GroupBy(e => e.Name, elementSelector, new AnagramEqualityComparer())); } [Fact] @@ -343,7 +343,7 @@ namespace System.Linq.Tests Func<Record, int> elementSelector = null; - Assert.Throws<ArgumentNullException>("elementSelector", () => source.GroupBy(e => e.Name, elementSelector, (k, es) => es.Sum())); + AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => source.GroupBy(e => e.Name, elementSelector, (k, es) => es.Sum())); } [Fact] @@ -360,7 +360,7 @@ namespace System.Linq.Tests Func<string, IEnumerable<int>, long> resultSelector = null; - Assert.Throws<ArgumentNullException>("resultSelector", () => source.GroupBy(e => e.Name, e => e.Score, resultSelector, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => source.GroupBy(e => e.Name, e => e.Score, resultSelector, new AnagramEqualityComparer())); } [Fact] @@ -377,7 +377,7 @@ namespace System.Linq.Tests Func<string, IEnumerable<int>, long> resultSelector = null; - Assert.Throws<ArgumentNullException>("resultSelector", () => source.GroupBy(e => e.Name, e => e.Score, resultSelector)); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => source.GroupBy(e => e.Name, e => e.Score, resultSelector)); } [Fact] @@ -394,7 +394,7 @@ namespace System.Linq.Tests Func<string, IEnumerable<Record>, long> resultSelector = null; - Assert.Throws<ArgumentNullException>("resultSelector", () => source.GroupBy(e => e.Name, resultSelector)); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => source.GroupBy(e => e.Name, resultSelector)); } [Fact] @@ -406,7 +406,7 @@ namespace System.Linq.Tests Func<string, IEnumerable<Record>, long> resultSelector = null; - Assert.Throws<ArgumentNullException>("resultSelector", () => source.GroupBy(e => e.Name, resultSelector, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => source.GroupBy(e => e.Name, resultSelector, new AnagramEqualityComparer())); } [Fact] @@ -909,4 +909,4 @@ namespace System.Linq.Tests // yield return new object[] { new int?[] { null }.GroupBy(x => x).Single(), "null", new int?(0), new int?(0) }; } } -}
\ No newline at end of file +} diff --git a/src/System.Linq/tests/GroupJoinTests.cs b/src/System.Linq/tests/GroupJoinTests.cs index 3fa53f4cec..4e732158d8 100644 --- a/src/System.Linq/tests/GroupJoinTests.cs +++ b/src/System.Linq/tests/GroupJoinTests.cs @@ -142,7 +142,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "miT", orderID = 93489, total = 45 } }; - Assert.Throws<ArgumentNullException>("outer", () => outer.GroupJoin(inner, e => e.name, e => e.name, createJoinRec, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("outer", () => outer.GroupJoin(inner, e => e.name, e => e.name, createJoinRec, new AnagramEqualityComparer())); } [Fact] @@ -156,7 +156,7 @@ namespace System.Linq.Tests }; AnagramRec[] inner = null; - Assert.Throws<ArgumentNullException>("inner", () => outer.GroupJoin(inner, e => e.name, e => e.name, createJoinRec, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("inner", () => outer.GroupJoin(inner, e => e.name, e => e.name, createJoinRec, new AnagramEqualityComparer())); } [Fact] @@ -174,7 +174,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "miT", orderID = 93489, total = 45 } }; - Assert.Throws<ArgumentNullException>("outerKeySelector", () => outer.GroupJoin(inner, null, e => e.name, createJoinRec, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("outerKeySelector", () => outer.GroupJoin(inner, null, e => e.name, createJoinRec, new AnagramEqualityComparer())); } [Fact] @@ -192,7 +192,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "miT", orderID = 93489, total = 45 } }; - Assert.Throws<ArgumentNullException>("innerKeySelector", () => outer.GroupJoin(inner, e => e.name, null, createJoinRec, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("innerKeySelector", () => outer.GroupJoin(inner, e => e.name, null, createJoinRec, new AnagramEqualityComparer())); } [Fact] @@ -210,7 +210,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "miT", orderID = 93489, total = 45 } }; - Assert.Throws<ArgumentNullException>("resultSelector", () => outer.GroupJoin(inner, e => e.name, e => e.name, (Func<CustomerRec, IEnumerable<AnagramRec>, JoinRec>)null, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => outer.GroupJoin(inner, e => e.name, e => e.name, (Func<CustomerRec, IEnumerable<AnagramRec>, JoinRec>)null, new AnagramEqualityComparer())); } [Fact] @@ -223,7 +223,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "miT", orderID = 93489, total = 45 } }; - Assert.Throws<ArgumentNullException>("outer", () => outer.GroupJoin(inner, e => e.name, e => e.name, createJoinRec)); + AssertExtensions.Throws<ArgumentNullException>("outer", () => outer.GroupJoin(inner, e => e.name, e => e.name, createJoinRec)); } [Fact] @@ -237,7 +237,7 @@ namespace System.Linq.Tests }; AnagramRec[] inner = null; - Assert.Throws<ArgumentNullException>("inner", () => outer.GroupJoin(inner, e => e.name, e => e.name, createJoinRec)); + AssertExtensions.Throws<ArgumentNullException>("inner", () => outer.GroupJoin(inner, e => e.name, e => e.name, createJoinRec)); } [Fact] @@ -255,7 +255,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "miT", orderID = 93489, total = 45 } }; - Assert.Throws<ArgumentNullException>("outerKeySelector", () => outer.GroupJoin(inner, null, e => e.name, createJoinRec)); + AssertExtensions.Throws<ArgumentNullException>("outerKeySelector", () => outer.GroupJoin(inner, null, e => e.name, createJoinRec)); } [Fact] @@ -273,7 +273,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "miT", orderID = 93489, total = 45 } }; - Assert.Throws<ArgumentNullException>("innerKeySelector", () => outer.GroupJoin(inner, e => e.name, null, createJoinRec)); + AssertExtensions.Throws<ArgumentNullException>("innerKeySelector", () => outer.GroupJoin(inner, e => e.name, null, createJoinRec)); } [Fact] @@ -291,7 +291,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "miT", orderID = 93489, total = 45 } }; - Assert.Throws<ArgumentNullException>("resultSelector", () => outer.GroupJoin(inner, e => e.name, e => e.name, (Func<CustomerRec, IEnumerable<AnagramRec>, JoinRec>)null)); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => outer.GroupJoin(inner, e => e.name, e => e.name, (Func<CustomerRec, IEnumerable<AnagramRec>, JoinRec>)null)); } [Fact] diff --git a/src/System.Linq/tests/IntersectTests.cs b/src/System.Linq/tests/IntersectTests.cs index dde5ea3f22..fba2336d98 100644 --- a/src/System.Linq/tests/IntersectTests.cs +++ b/src/System.Linq/tests/IntersectTests.cs @@ -97,8 +97,8 @@ namespace System.Linq.Tests string[] first = null; string[] second = { "ekiM", "bBo" }; - Assert.Throws<ArgumentNullException>("first", () => first.Intersect(second)); - Assert.Throws<ArgumentNullException>("first", () => first.Intersect(second, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("first", () => first.Intersect(second)); + AssertExtensions.Throws<ArgumentNullException>("first", () => first.Intersect(second, new AnagramEqualityComparer())); } [Fact] @@ -107,8 +107,8 @@ namespace System.Linq.Tests string[] first = { "Tim", "Bob", "Mike", "Robert" }; string[] second = null; - Assert.Throws<ArgumentNullException>("second", () => first.Intersect(second)); - Assert.Throws<ArgumentNullException>("second", () => first.Intersect(second, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("second", () => first.Intersect(second)); + AssertExtensions.Throws<ArgumentNullException>("second", () => first.Intersect(second, new AnagramEqualityComparer())); } [Fact] diff --git a/src/System.Linq/tests/JoinTests.cs b/src/System.Linq/tests/JoinTests.cs index 0195d849bf..72ebf031d6 100644 --- a/src/System.Linq/tests/JoinTests.cs +++ b/src/System.Linq/tests/JoinTests.cs @@ -135,7 +135,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "Prakash", orderID = 323232, total = 9 } }; - Assert.Throws<ArgumentNullException>("outer", () => outer.Join(inner, e => e.name, e => e.name, createJoinRec, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("outer", () => outer.Join(inner, e => e.name, e => e.name, createJoinRec, new AnagramEqualityComparer())); } [Fact] @@ -149,7 +149,7 @@ namespace System.Linq.Tests }; AnagramRec[] inner = null; - Assert.Throws<ArgumentNullException>("inner", () => outer.Join(inner, e => e.name, e => e.name, createJoinRec, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("inner", () => outer.Join(inner, e => e.name, e => e.name, createJoinRec, new AnagramEqualityComparer())); } [Fact] @@ -167,7 +167,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "Prakash", orderID = 323232, total = 9 } }; - Assert.Throws<ArgumentNullException>("outerKeySelector", () => outer.Join(inner, null, e => e.name, createJoinRec, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("outerKeySelector", () => outer.Join(inner, null, e => e.name, createJoinRec, new AnagramEqualityComparer())); } [Fact] @@ -185,7 +185,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "Prakash", orderID = 323232, total = 9 } }; - Assert.Throws<ArgumentNullException>("innerKeySelector", () => outer.Join(inner, e => e.name, null, createJoinRec, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("innerKeySelector", () => outer.Join(inner, e => e.name, null, createJoinRec, new AnagramEqualityComparer())); } [Fact] @@ -203,7 +203,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "Prakash", orderID = 323232, total = 9 } }; - Assert.Throws<ArgumentNullException>("resultSelector", () => outer.Join(inner, e => e.name, e => e.name, (Func<CustomerRec, AnagramRec, JoinRec>)null, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => outer.Join(inner, e => e.name, e => e.name, (Func<CustomerRec, AnagramRec, JoinRec>)null, new AnagramEqualityComparer())); } [Fact] @@ -216,7 +216,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "Prakash", orderID = 323232, total = 9 } }; - Assert.Throws<ArgumentNullException>("outer", () => outer.Join(inner, e => e.name, e => e.name, createJoinRec)); + AssertExtensions.Throws<ArgumentNullException>("outer", () => outer.Join(inner, e => e.name, e => e.name, createJoinRec)); } [Fact] @@ -230,7 +230,7 @@ namespace System.Linq.Tests }; AnagramRec[] inner = null; - Assert.Throws<ArgumentNullException>("inner", () => outer.Join(inner, e => e.name, e => e.name, createJoinRec)); + AssertExtensions.Throws<ArgumentNullException>("inner", () => outer.Join(inner, e => e.name, e => e.name, createJoinRec)); } [Fact] @@ -248,7 +248,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "Prakash", orderID = 323232, total = 9 } }; - Assert.Throws<ArgumentNullException>("outerKeySelector", () => outer.Join(inner, null, e => e.name, createJoinRec)); + AssertExtensions.Throws<ArgumentNullException>("outerKeySelector", () => outer.Join(inner, null, e => e.name, createJoinRec)); } [Fact] @@ -266,7 +266,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "Prakash", orderID = 323232, total = 9 } }; - Assert.Throws<ArgumentNullException>("innerKeySelector", () => outer.Join(inner, e => e.name, null, createJoinRec)); + AssertExtensions.Throws<ArgumentNullException>("innerKeySelector", () => outer.Join(inner, e => e.name, null, createJoinRec)); } [Fact] @@ -284,7 +284,7 @@ namespace System.Linq.Tests new AnagramRec{ name = "Prakash", orderID = 323232, total = 9 } }; - Assert.Throws<ArgumentNullException>("resultSelector", () => outer.Join(inner, e => e.name, e => e.name, (Func<CustomerRec, AnagramRec, JoinRec>)null)); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => outer.Join(inner, e => e.name, e => e.name, (Func<CustomerRec, AnagramRec, JoinRec>)null)); } [Fact] diff --git a/src/System.Linq/tests/LastOrDefaultTests.cs b/src/System.Linq/tests/LastOrDefaultTests.cs index b1363dae2b..a436286e75 100644 --- a/src/System.Linq/tests/LastOrDefaultTests.cs +++ b/src/System.Linq/tests/LastOrDefaultTests.cs @@ -250,20 +250,20 @@ namespace System.Linq.Tests [Fact] public void NullSource() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).LastOrDefault()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).LastOrDefault()); } [Fact] public void NullSourcePredicateUsed() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).LastOrDefault(i => i != 2)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).LastOrDefault(i => i != 2)); } [Fact] public void NullPredicate() { Func<int, bool> predicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).LastOrDefault(predicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).LastOrDefault(predicate)); } } } diff --git a/src/System.Linq/tests/LastTests.cs b/src/System.Linq/tests/LastTests.cs index b8864d9ff4..090de092d4 100644 --- a/src/System.Linq/tests/LastTests.cs +++ b/src/System.Linq/tests/LastTests.cs @@ -245,20 +245,20 @@ namespace System.Linq.Tests [Fact] public void NullSource() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Last()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Last()); } [Fact] public void NullSourcePredicateUsed() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Last(i => i != 2)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Last(i => i != 2)); } [Fact] public void NullPredicate() { Func<int, bool> predicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Last(predicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Last(predicate)); } } } diff --git a/src/System.Linq/tests/LongCountTests.cs b/src/System.Linq/tests/LongCountTests.cs index dbbf2b6d44..699b1314ba 100644 --- a/src/System.Linq/tests/LongCountTests.cs +++ b/src/System.Linq/tests/LongCountTests.cs @@ -80,15 +80,15 @@ namespace System.Linq.Tests [Fact] public void NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).LongCount()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).LongCount(i => i != 0)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).LongCount()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).LongCount(i => i != 0)); } [Fact] public void NullPredicate_ThrowsArgumentNullException() { Func<int, bool> predicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).LongCount(predicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).LongCount(predicate)); } } } diff --git a/src/System.Linq/tests/MaxTests.cs b/src/System.Linq/tests/MaxTests.cs index 8d06f5856b..725089f259 100644 --- a/src/System.Linq/tests/MaxTests.cs +++ b/src/System.Linq/tests/MaxTests.cs @@ -32,8 +32,8 @@ namespace System.Linq.Tests [Fact] public void Max_Int_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Max(i => i)); } [Fact] @@ -92,8 +92,8 @@ namespace System.Linq.Tests [Fact] public void Max_Long_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Max(i => i)); } [Fact] @@ -144,8 +144,8 @@ namespace System.Linq.Tests [Fact] public void Max_Float_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Max(i => i)); } [Fact] @@ -215,8 +215,8 @@ namespace System.Linq.Tests [Fact] public void Max_Double_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Max(i => i)); } [Fact] @@ -272,8 +272,8 @@ namespace System.Linq.Tests [Fact] public void Max_Decimal_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Max(i => i)); } [Fact] @@ -318,8 +318,8 @@ namespace System.Linq.Tests [Fact] public void Max_NullableInt_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Max(i => i)); } public static IEnumerable<object[]> Max_NullableLong_TestData() @@ -350,8 +350,8 @@ namespace System.Linq.Tests [Fact] public void Max_NullableLong_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Max(i => i)); } public static IEnumerable<object[]> Max_NullableFloat_TestData() @@ -391,8 +391,8 @@ namespace System.Linq.Tests [Fact] public void Max_NullableFloat_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Max(i => i)); } public static IEnumerable<object[]> Max_NullableDouble_TestData() @@ -432,8 +432,8 @@ namespace System.Linq.Tests [Fact] public void Max_NullableDouble_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Max(i => i)); } public static IEnumerable<object[]> Max_NullableDecimal_TestData() @@ -464,8 +464,8 @@ namespace System.Linq.Tests [Fact] public void Max_NullableDecimal_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Max(i => i)); } public static IEnumerable<object[]> Max_DateTime_TestData() @@ -495,8 +495,8 @@ namespace System.Linq.Tests [Fact] public void Max_DateTime_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Max(i => i)); } [Fact] @@ -539,15 +539,15 @@ namespace System.Linq.Tests [Fact] public void Max_String_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<string>)null).Max()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<string>)null).Max(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<string>)null).Max()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<string>)null).Max(i => i)); } [Fact] public void Max_Int_NullSelector_ThrowsArgumentNullException() { Func<int, int> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int>().Max(selector)); } [Fact] @@ -567,7 +567,7 @@ namespace System.Linq.Tests public void Max_Long_NullSelector_ThrowsArgumentNullException() { Func<long, long> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long>().Max(selector)); } [Fact] @@ -599,14 +599,14 @@ namespace System.Linq.Tests public void Max_Float_NullSelector_ThrowsArgumentNullException() { Func<float, float> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float>().Max(selector)); } [Fact] public void Max_Double_NullSelector_ThrowsArgumentNullException() { Func<double, double> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double>().Max(selector)); } [Fact] @@ -625,7 +625,7 @@ namespace System.Linq.Tests public void Max_Decimal_NullSelector_ThrowsArgumentNullException() { Func<decimal, decimal> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal>().Max(selector)); } [Fact] @@ -643,7 +643,7 @@ namespace System.Linq.Tests public void Max_NullableInt_NullSelector_ThrowsArgumentNullException() { Func<int?, int?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int?>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int?>().Max(selector)); } [Fact] @@ -662,7 +662,7 @@ namespace System.Linq.Tests public void Max_NullableLong_NullSelector_ThrowsArgumentNullException() { Func<long?, long?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long?>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long?>().Max(selector)); } [Fact] @@ -681,7 +681,7 @@ namespace System.Linq.Tests public void Max_NullableFloat_NullSelector_ThrowsArgumentNullException() { Func<float?, float?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float?>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float?>().Max(selector)); } [Fact] @@ -700,7 +700,7 @@ namespace System.Linq.Tests public void Max_NullableDouble_NullSelector_ThrowsArgumentNullException() { Func<double?, double?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double?>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double?>().Max(selector)); } [Fact] @@ -719,7 +719,7 @@ namespace System.Linq.Tests public void Max_NullableDecimal_NullSelector_ThrowsArgumentNullException() { Func<decimal?, decimal?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal?>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal?>().Max(selector)); } [Fact] @@ -744,14 +744,14 @@ namespace System.Linq.Tests public void Max_NullableDateTime_NullSelector_ThrowsArgumentNullException() { Func<DateTime?, DateTime?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<DateTime?>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<DateTime?>().Max(selector)); } [Fact] public void Max_String_NullSelector_ThrowsArgumentNullException() { Func<string, string> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<string>().Max(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<string>().Max(selector)); } [Fact] diff --git a/src/System.Linq/tests/MinTests.cs b/src/System.Linq/tests/MinTests.cs index c75eaa2a89..d96947da43 100644 --- a/src/System.Linq/tests/MinTests.cs +++ b/src/System.Linq/tests/MinTests.cs @@ -56,8 +56,8 @@ namespace System.Linq.Tests [Fact] public void Min_Int_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Min(x => x)); } [Fact] @@ -93,8 +93,8 @@ namespace System.Linq.Tests [Fact] public void Min_Long_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Min(x => x)); } [Fact] @@ -155,8 +155,8 @@ namespace System.Linq.Tests [Fact] public void Min_Float_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Min(x => x)); } [Fact] @@ -216,8 +216,8 @@ namespace System.Linq.Tests [Fact] public void Min_Double_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Min(x => x)); } [Fact] @@ -260,8 +260,8 @@ namespace System.Linq.Tests [Fact] public void Min_Decimal_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Min(x => x)); } public static IEnumerable<object[]> Min_NullableInt_TestData() @@ -297,8 +297,8 @@ namespace System.Linq.Tests [Fact] public void Min_NullableInt_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Min(x => x)); } public static IEnumerable<object[]> Min_NullableLong_TestData() @@ -328,8 +328,8 @@ namespace System.Linq.Tests [Fact] public void Min_NullableLong_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Min(x => x)); } public static IEnumerable<object[]> Min_NullableFloat_TestData() @@ -378,8 +378,8 @@ namespace System.Linq.Tests [Fact] public void Min_NullableFloat_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Min(x => x)); } public static IEnumerable<object[]> Min_NullableDouble_TestData() @@ -428,7 +428,7 @@ namespace System.Linq.Tests [Fact] public void Min_NullableDouble_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Min()); } public static IEnumerable<object[]> Min_NullableDecimal_TestData() @@ -459,8 +459,8 @@ namespace System.Linq.Tests [Fact] public void Min_NullableDecimal_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Min(x => x)); } public static IEnumerable<object[]> Min_DateTime_TestData() @@ -490,8 +490,8 @@ namespace System.Linq.Tests [Fact] public void Min_DateTime_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Min(x => x)); } [Fact] @@ -534,8 +534,8 @@ namespace System.Linq.Tests [Fact] public void Min_String_NullSource_ThrowsArgumentNullException() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<string>)null).Min()); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<string>)null).Min(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<string>)null).Min()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<string>)null).Min(x => x)); } [Fact] @@ -554,7 +554,7 @@ namespace System.Linq.Tests public void Min_Int_NullSelector_ThrowsArgumentNullException() { Func<int, int> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int>().Min(selector)); } [Fact] @@ -574,7 +574,7 @@ namespace System.Linq.Tests public void Min_Long_NullSelector_ThrowsArgumentNullException() { Func<long, long> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long>().Min(selector)); } [Fact] @@ -593,7 +593,7 @@ namespace System.Linq.Tests public void Min_Float_NullSelector_ThrowsArgumentNullException() { Func<float, float> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float>().Min(selector)); } [Fact] @@ -612,7 +612,7 @@ namespace System.Linq.Tests public void Min_Double_NullSelector_ThrowsArgumentNullException() { Func<double, double> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double>().Min(selector)); } [Fact] @@ -631,7 +631,7 @@ namespace System.Linq.Tests public void Min_Decimal_NullSelector_ThrowsArgumentNullException() { Func<decimal, decimal> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal>().Min(selector)); } [Fact] @@ -650,7 +650,7 @@ namespace System.Linq.Tests public void Min_NullableInt_NullSelector_ThrowsArgumentNullException() { Func<int?, int?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int?>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int?>().Min(selector)); } [Fact] @@ -669,7 +669,7 @@ namespace System.Linq.Tests public void Min_NullableLong_NullSelector_ThrowsArgumentNullException() { Func<long?, long?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long?>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long?>().Min(selector)); } [Fact] @@ -689,7 +689,7 @@ namespace System.Linq.Tests public void Min_NullableFloat_NullSelector_ThrowsArgumentNullException() { Func<float?, float?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float?>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float?>().Min(selector)); } [Fact] @@ -708,7 +708,7 @@ namespace System.Linq.Tests public void Min_NullableDouble_NullSelector_ThrowsArgumentNullException() { Func<double?, double?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double?>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double?>().Min(selector)); } [Fact] @@ -727,14 +727,14 @@ namespace System.Linq.Tests public void Min_NullableDecimal_NullSelector_ThrowsArgumentNullException() { Func<decimal?, decimal?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal?>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal?>().Min(selector)); } [Fact] public void Min_DateTime_NullSelector_ThrowsArgumentNullException() { Func<DateTime, DateTime> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<DateTime>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<DateTime>().Min(selector)); } [Fact] @@ -753,7 +753,7 @@ namespace System.Linq.Tests public void Min_String_NullSelector_ThrowsArgumentNullException() { Func<string, string> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<string>().Min(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<string>().Min(selector)); } [Fact] diff --git a/src/System.Linq/tests/OfTypeTests.cs b/src/System.Linq/tests/OfTypeTests.cs index 67992d0f51..e7c164a317 100644 --- a/src/System.Linq/tests/OfTypeTests.cs +++ b/src/System.Linq/tests/OfTypeTests.cs @@ -123,7 +123,7 @@ namespace System.Linq.Tests [Fact] public void NullSource() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<object>)null).OfType<string>()); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<object>)null).OfType<string>()); } [Fact] diff --git a/src/System.Linq/tests/OrderByDescendingTests.cs b/src/System.Linq/tests/OrderByDescendingTests.cs index 44352051da..d2e1b6a749 100644 --- a/src/System.Linq/tests/OrderByDescendingTests.cs +++ b/src/System.Linq/tests/OrderByDescendingTests.cs @@ -175,14 +175,14 @@ namespace System.Linq.Tests public void NullSource() { IEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.OrderByDescending(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.OrderByDescending(i => i)); } [Fact] public void NullKeySelector() { Func<DateTime, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderByDescending(keySelector)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderByDescending(keySelector)); } } } diff --git a/src/System.Linq/tests/OrderByTests.cs b/src/System.Linq/tests/OrderByTests.cs index 9dbff46c38..c98bb251ba 100644 --- a/src/System.Linq/tests/OrderByTests.cs +++ b/src/System.Linq/tests/OrderByTests.cs @@ -264,14 +264,14 @@ namespace System.Linq.Tests public void NullSource() { IEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.OrderBy(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.OrderBy(i => i)); } [Fact] public void NullKeySelector() { Func<DateTime, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(keySelector)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(keySelector)); } [Fact] diff --git a/src/System.Linq/tests/OrderedSubsetting.cs b/src/System.Linq/tests/OrderedSubsetting.cs index 544dd14327..eebbc65692 100644 --- a/src/System.Linq/tests/OrderedSubsetting.cs +++ b/src/System.Linq/tests/OrderedSubsetting.cs @@ -428,7 +428,7 @@ namespace System.Linq.Tests Assert.Equal(6, source.ElementAt(2)); Assert.Equal(8, source.ElementAtOrDefault(3)); Assert.Equal(0, source.ElementAtOrDefault(8)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(-2)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(-2)); } [Fact] diff --git a/src/System.Linq/tests/RangeTests.cs b/src/System.Linq/tests/RangeTests.cs index 1acb731fac..dfa06d75dc 100644 --- a/src/System.Linq/tests/RangeTests.cs +++ b/src/System.Linq/tests/RangeTests.cs @@ -59,16 +59,16 @@ namespace System.Linq.Tests [Fact] public void Range_ThrowExceptionOnNegativeCount() { - Assert.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(1, -1)); - Assert.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(1, int.MinValue)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(1, -1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(1, int.MinValue)); } [Fact] public void Range_ThrowExceptionOnOverflow() { - Assert.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(1000, int.MaxValue)); - Assert.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(int.MaxValue, 1000)); - Assert.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(Int32.MaxValue - 10, 20)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(1000, int.MaxValue)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(int.MaxValue, 1000)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Range(Int32.MaxValue - 10, 20)); } [Fact] @@ -185,7 +185,7 @@ namespace System.Linq.Tests [Fact] public void ElementAtExcessiveThrows() { - Assert.Throws<ArgumentOutOfRangeException>("index", () => Enumerable.Range(0, 10).ElementAt(100)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => Enumerable.Range(0, 10).ElementAt(100)); } [Fact] diff --git a/src/System.Linq/tests/RepeatTests.cs b/src/System.Linq/tests/RepeatTests.cs index e24403edca..371f515357 100644 --- a/src/System.Linq/tests/RepeatTests.cs +++ b/src/System.Linq/tests/RepeatTests.cs @@ -76,7 +76,7 @@ namespace System.Linq.Tests [Fact] public void Repeat_ThrowExceptionOnNegativeCount() { - Assert.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Repeat(1, -1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => Enumerable.Repeat(1, -1)); } @@ -226,7 +226,7 @@ namespace System.Linq.Tests [Fact] public void ElementAtExcessive() { - Assert.Throws<ArgumentOutOfRangeException>("index", () => Enumerable.Repeat(3, 3).ElementAt(100)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => Enumerable.Repeat(3, 3).ElementAt(100)); } [Fact] diff --git a/src/System.Linq/tests/ReverseTests.cs b/src/System.Linq/tests/ReverseTests.cs index c8b9cb6048..826a39add9 100644 --- a/src/System.Linq/tests/ReverseTests.cs +++ b/src/System.Linq/tests/ReverseTests.cs @@ -12,7 +12,7 @@ namespace System.Linq.Tests [Fact] public void InvalidArguments() { - Assert.Throws<ArgumentNullException>("source", () => Enumerable.Reverse<string>(null)); + AssertExtensions.Throws<ArgumentNullException>("source", () => Enumerable.Reverse<string>(null)); } [Theory] diff --git a/src/System.Linq/tests/SelectManyTests.cs b/src/System.Linq/tests/SelectManyTests.cs index 96218a28f6..10eb908b72 100644 --- a/src/System.Linq/tests/SelectManyTests.cs +++ b/src/System.Linq/tests/SelectManyTests.cs @@ -245,70 +245,70 @@ namespace System.Linq.Tests public void NullResultSelector() { Func<StringWithIntArray, int?, string> resultSelector = null; - Assert.Throws<ArgumentNullException>("resultSelector", () => Enumerable.Empty<StringWithIntArray>().SelectMany(e => e.total, resultSelector)); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => Enumerable.Empty<StringWithIntArray>().SelectMany(e => e.total, resultSelector)); } [Fact] public void NullResultSelectorIndexedSelector() { Func<StringWithIntArray, int?, string> resultSelector = null; - Assert.Throws<ArgumentNullException>("resultSelector", () => Enumerable.Empty<StringWithIntArray>().SelectMany((e, i) => e.total, resultSelector)); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => Enumerable.Empty<StringWithIntArray>().SelectMany((e, i) => e.total, resultSelector)); } [Fact] public void NullSourceWithResultSelector() { StringWithIntArray[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.SelectMany(e => e.total, (e, f) => f.ToString())); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.SelectMany(e => e.total, (e, f) => f.ToString())); } [Fact] public void NullCollectionSelector() { Func<StringWithIntArray, IEnumerable<int?>> collectionSelector = null; - Assert.Throws<ArgumentNullException>("collectionSelector", () => Enumerable.Empty<StringWithIntArray>().SelectMany(collectionSelector, (e, f) => f.ToString())); + AssertExtensions.Throws<ArgumentNullException>("collectionSelector", () => Enumerable.Empty<StringWithIntArray>().SelectMany(collectionSelector, (e, f) => f.ToString())); } [Fact] public void NullIndexedCollectionSelector() { Func<StringWithIntArray, int, IEnumerable<int?>> collectionSelector = null; - Assert.Throws<ArgumentNullException>("collectionSelector", () => Enumerable.Empty<StringWithIntArray>().SelectMany(collectionSelector, (e, f) => f.ToString())); + AssertExtensions.Throws<ArgumentNullException>("collectionSelector", () => Enumerable.Empty<StringWithIntArray>().SelectMany(collectionSelector, (e, f) => f.ToString())); } [Fact] public void NullSource() { StringWithIntArray[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.SelectMany(e => e.total)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.SelectMany(e => e.total)); } [Fact] public void NullSourceIndexedSelector() { StringWithIntArray[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.SelectMany((e, i) => e.total)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.SelectMany((e, i) => e.total)); } [Fact] public void NullSourceIndexedSelectorWithResultSelector() { StringWithIntArray[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.SelectMany((e, i) => e.total, (e, f) => f.ToString())); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.SelectMany((e, i) => e.total, (e, f) => f.ToString())); } [Fact] public void NullSelector() { Func<StringWithIntArray, int[]> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => new StringWithIntArray[0].SelectMany(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => new StringWithIntArray[0].SelectMany(selector)); } [Fact] public void NullIndexedSelector() { Func<StringWithIntArray, int, int[]> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => new StringWithIntArray[0].SelectMany(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => new StringWithIntArray[0].SelectMany(selector)); } [Fact] diff --git a/src/System.Linq/tests/SelectTests.cs b/src/System.Linq/tests/SelectTests.cs index c8ebbe64b5..ca84c7e928 100644 --- a/src/System.Linq/tests/SelectTests.cs +++ b/src/System.Linq/tests/SelectTests.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -159,7 +160,7 @@ namespace System.Linq.Tests IEnumerable<int> source = null; Func<int, int> selector = i => i + 1; - Assert.Throws<ArgumentNullException>("source", () => source.Select(selector)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Select(selector)); } [Fact] @@ -168,7 +169,7 @@ namespace System.Linq.Tests IEnumerable<int> source = Enumerable.Range(1, 10); Func<int, int, int> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => source.Select(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => source.Select(selector)); } [Fact] @@ -177,7 +178,7 @@ namespace System.Linq.Tests IEnumerable<int> source = null; Func<int, int, int> selector = (e, i) => i + 1; - Assert.Throws<ArgumentNullException>("source", () => source.Select(selector)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Select(selector)); } [Fact] @@ -186,7 +187,7 @@ namespace System.Linq.Tests IEnumerable<int> source = Enumerable.Range(1, 10); Func<int, int> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => source.Select(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => source.Select(selector)); } [Fact] public void Select_SourceIsAnArray_ExecutionIsDeferred() @@ -908,12 +909,12 @@ namespace System.Linq.Tests var source = new[] { 1, 2, 3, 4 }.Select(i => i * 2); for (int i = 0; i != 4; ++i) Assert.Equal(i * 2 + 2, source.ElementAt(i)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(-1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(4)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(40)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(-1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(4)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(40)); Assert.Equal(6, source.Skip(1).ElementAt(1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.Skip(2).ElementAt(9)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.Skip(2).ElementAt(9)); } [Fact] @@ -922,12 +923,12 @@ namespace System.Linq.Tests var source = new List<int> { 1, 2, 3, 4 }.Select(i => i * 2); for (int i = 0; i != 4; ++i) Assert.Equal(i * 2 + 2, source.ElementAt(i)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(-1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(4)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(40)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(-1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(4)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(40)); Assert.Equal(6, source.Skip(1).ElementAt(1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.Skip(2).ElementAt(9)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.Skip(2).ElementAt(9)); } [Fact] @@ -936,12 +937,12 @@ namespace System.Linq.Tests var source = new List<int> { 1, 2, 3, 4 }.AsReadOnly().Select(i => i * 2); for (int i = 0; i != 4; ++i) Assert.Equal(i * 2 + 2, source.ElementAt(i)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(-1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(4)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(40)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(-1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(4)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.ElementAt(40)); Assert.Equal(6, source.Skip(1).ElementAt(1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => source.Skip(2).ElementAt(9)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => source.Skip(2).ElementAt(9)); } [Fact] diff --git a/src/System.Linq/tests/SequenceEqualTests.cs b/src/System.Linq/tests/SequenceEqualTests.cs index 8426455b40..1f96cf96a0 100644 --- a/src/System.Linq/tests/SequenceEqualTests.cs +++ b/src/System.Linq/tests/SequenceEqualTests.cs @@ -204,7 +204,7 @@ namespace System.Linq.Tests int[] first = null; int[] second = { }; - Assert.Throws<ArgumentNullException>("first", () => first.SequenceEqual(second)); + AssertExtensions.Throws<ArgumentNullException>("first", () => first.SequenceEqual(second)); } [Fact] @@ -213,7 +213,7 @@ namespace System.Linq.Tests int[] first = { }; int[] second = null; - Assert.Throws<ArgumentNullException>("second", () => first.SequenceEqual(second)); + AssertExtensions.Throws<ArgumentNullException>("second", () => first.SequenceEqual(second)); } } } diff --git a/src/System.Linq/tests/SingleOrDefaultTests.cs b/src/System.Linq/tests/SingleOrDefaultTests.cs index 021121f43e..0dbcfc18df 100644 --- a/src/System.Linq/tests/SingleOrDefaultTests.cs +++ b/src/System.Linq/tests/SingleOrDefaultTests.cs @@ -153,8 +153,8 @@ namespace System.Linq.Tests public void ThrowsOnNullSource() { int[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.SingleOrDefault()); - Assert.Throws<ArgumentNullException>("source", () => source.SingleOrDefault(i => i % 2 == 0)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.SingleOrDefault()); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.SingleOrDefault(i => i % 2 == 0)); } [Fact] @@ -162,7 +162,7 @@ namespace System.Linq.Tests { int[] source = { }; Func<int, bool> nullPredicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => source.SingleOrDefault(nullPredicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => source.SingleOrDefault(nullPredicate)); } } } diff --git a/src/System.Linq/tests/SingleTests.cs b/src/System.Linq/tests/SingleTests.cs index 7de92a49e2..a7238301ba 100644 --- a/src/System.Linq/tests/SingleTests.cs +++ b/src/System.Linq/tests/SingleTests.cs @@ -157,8 +157,8 @@ namespace System.Linq.Tests public void ThrowsOnNullSource() { int[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.Single()); - Assert.Throws<ArgumentNullException>("source", () => source.Single(i => i % 2 == 0)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Single()); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Single(i => i % 2 == 0)); } [Fact] @@ -166,7 +166,7 @@ namespace System.Linq.Tests { int[] source = { }; Func<int, bool> nullPredicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => source.Single(nullPredicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => source.Single(nullPredicate)); } } } diff --git a/src/System.Linq/tests/SkipTests.cs b/src/System.Linq/tests/SkipTests.cs index e12ab97f00..e876a24aab 100644 --- a/src/System.Linq/tests/SkipTests.cs +++ b/src/System.Linq/tests/SkipTests.cs @@ -75,14 +75,14 @@ namespace System.Linq.Tests [Fact] public void SkipThrowsOnNull() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Skip(3)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<DateTime>)null).Skip(3)); } [Fact] public void SkipThrowsOnNullIList() { - Assert.Throws<ArgumentNullException>("source", () => ((List<DateTime>)null).Skip(3)); - Assert.Throws<ArgumentNullException>("source", () => ((IList<DateTime>)null).Skip(3)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((List<DateTime>)null).Skip(3)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IList<DateTime>)null).Skip(3)); } [Fact] @@ -285,8 +285,8 @@ namespace System.Linq.Tests Assert.Equal(3, remaining.ElementAt(0)); Assert.Equal(4, remaining.ElementAt(1)); Assert.Equal(6, remaining.ElementAt(3)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => remaining.ElementAt(-1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => remaining.ElementAt(4)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => remaining.ElementAt(-1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => remaining.ElementAt(4)); } [Fact] @@ -297,8 +297,8 @@ namespace System.Linq.Tests Assert.Equal(3, remaining.ElementAt(0)); Assert.Equal(4, remaining.ElementAt(1)); Assert.Equal(6, remaining.ElementAt(3)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => remaining.ElementAt(-1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => remaining.ElementAt(4)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => remaining.ElementAt(-1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => remaining.ElementAt(4)); } [Fact] diff --git a/src/System.Linq/tests/SkipWhileTests.cs b/src/System.Linq/tests/SkipWhileTests.cs index 6cf64ece03..8ab78edf43 100644 --- a/src/System.Linq/tests/SkipWhileTests.cs +++ b/src/System.Linq/tests/SkipWhileTests.cs @@ -28,10 +28,10 @@ namespace System.Linq.Tests [Fact] public void SkipWhileThrowsOnNull() { - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).SkipWhile(i => i < 40)); - Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).SkipWhile((i, idx) => i == idx)); - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 20).SkipWhile((Func<int, int, bool>)null)); - Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 20).SkipWhile((Func<int, bool>)null)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).SkipWhile(i => i < 40)); + AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).SkipWhile((i, idx) => i == idx)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 20).SkipWhile((Func<int, int, bool>)null)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 20).SkipWhile((Func<int, bool>)null)); } [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/Microsoft/BashOnWindows/issues/513 diff --git a/src/System.Linq/tests/SumTests.cs b/src/System.Linq/tests/SumTests.cs index 47353f7634..18c3c507cd 100644 --- a/src/System.Linq/tests/SumTests.cs +++ b/src/System.Linq/tests/SumTests.cs @@ -15,80 +15,80 @@ namespace System.Linq.Tests public void SumOfInt_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<int> sourceInt = null; - Assert.Throws<ArgumentNullException>("source", () => sourceInt.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceInt.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceInt.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceInt.Sum(x => x)); } [Fact] public void SumOfNullableOfInt_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<int?> sourceNullableInt = null; - Assert.Throws<ArgumentNullException>("source", () => sourceNullableInt.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceNullableInt.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableInt.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableInt.Sum(x => x)); } [Fact] public void SumOfLong_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<long> sourceLong = null; - Assert.Throws<ArgumentNullException>("source", () => sourceLong.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceLong.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceLong.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceLong.Sum(x => x)); } [Fact] public void SumOfNullableOfLong_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<long?> sourceNullableLong = null; - Assert.Throws<ArgumentNullException>("source", () => sourceNullableLong.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceNullableLong.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableLong.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableLong.Sum(x => x)); } [Fact] public void SumOfFloat_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<float> sourceFloat = null; - Assert.Throws<ArgumentNullException>("source", () => sourceFloat.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceFloat.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceFloat.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceFloat.Sum(x => x)); } [Fact] public void SumOfNullableOfFloat_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<float?> sourceNullableFloat = null; - Assert.Throws<ArgumentNullException>("source", () => sourceNullableFloat.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceNullableFloat.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableFloat.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableFloat.Sum(x => x)); } [Fact] public void SumOfDouble_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<double> sourceDouble = null; - Assert.Throws<ArgumentNullException>("source", () => sourceDouble.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceDouble.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceDouble.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceDouble.Sum(x => x)); } [Fact] public void SumOfNullableOfDouble_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<double?> sourceNullableDouble = null; - Assert.Throws<ArgumentNullException>("source", () => sourceNullableDouble.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceNullableDouble.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableDouble.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableDouble.Sum(x => x)); } [Fact] public void SumOfDecimal_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<decimal> sourceDecimal = null; - Assert.Throws<ArgumentNullException>("source", () => sourceDecimal.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceDecimal.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceDecimal.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceDecimal.Sum(x => x)); } [Fact] public void SumOfNullableOfDecimal_SourceIsNull_ArgumentNullExceptionThrown() { IEnumerable<decimal?> sourceNullableDecimal = null; - Assert.Throws<ArgumentNullException>("source", () => sourceNullableDecimal.Sum()); - Assert.Throws<ArgumentNullException>("source", () => sourceNullableDecimal.Sum(x => x)); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableDecimal.Sum()); + AssertExtensions.Throws<ArgumentNullException>("source", () => sourceNullableDecimal.Sum(x => x)); } #endregion @@ -100,7 +100,7 @@ namespace System.Linq.Tests { IEnumerable<int> sourceInt = Enumerable.Empty<int>(); Func<int, int> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceInt.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceInt.Sum(selector)); } [Fact] @@ -109,7 +109,7 @@ namespace System.Linq.Tests IEnumerable<int?> sourceNullableInt = Enumerable.Empty<int?>(); Func<int?, int?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceNullableInt.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceNullableInt.Sum(selector)); } [Fact] @@ -117,7 +117,7 @@ namespace System.Linq.Tests { IEnumerable<long> sourceLong = Enumerable.Empty<long>(); Func<long, long> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceLong.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceLong.Sum(selector)); } [Fact] @@ -126,7 +126,7 @@ namespace System.Linq.Tests IEnumerable<long?> sourceNullableLong = Enumerable.Empty<long?>(); Func<long?, long?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceNullableLong.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceNullableLong.Sum(selector)); } [Fact] @@ -134,7 +134,7 @@ namespace System.Linq.Tests { IEnumerable<float> sourceFloat = Enumerable.Empty<float>(); Func<float, float> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceFloat.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceFloat.Sum(selector)); } [Fact] @@ -143,7 +143,7 @@ namespace System.Linq.Tests IEnumerable<float?> sourceNullableFloat = Enumerable.Empty<float?>(); Func<float?, float?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceNullableFloat.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceNullableFloat.Sum(selector)); } [Fact] @@ -151,7 +151,7 @@ namespace System.Linq.Tests { IEnumerable<double> sourceDouble = Enumerable.Empty<double>(); Func<double, double> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceDouble.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceDouble.Sum(selector)); } [Fact] @@ -160,7 +160,7 @@ namespace System.Linq.Tests IEnumerable<double?> sourceNullableDouble = Enumerable.Empty<double?>(); Func<double?, double?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceNullableDouble.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceNullableDouble.Sum(selector)); } [Fact] @@ -168,7 +168,7 @@ namespace System.Linq.Tests { IEnumerable<decimal> sourceDecimal = Enumerable.Empty<decimal>(); Func<decimal, decimal> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceDecimal.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceDecimal.Sum(selector)); } [Fact] @@ -177,7 +177,7 @@ namespace System.Linq.Tests IEnumerable<decimal?> sourceNullableDecimal = Enumerable.Empty<decimal?>(); Func<decimal?, decimal?> selector = null; - Assert.Throws<ArgumentNullException>("selector", () => sourceNullableDecimal.Sum(selector)); + AssertExtensions.Throws<ArgumentNullException>("selector", () => sourceNullableDecimal.Sum(selector)); } #endregion diff --git a/src/System.Linq/tests/System.Linq.Tests.csproj b/src/System.Linq/tests/System.Linq.Tests.csproj index d9376de974..236ad0a2c7 100644 --- a/src/System.Linq/tests/System.Linq.Tests.csproj +++ b/src/System.Linq/tests/System.Linq.Tests.csproj @@ -76,6 +76,9 @@ <Compile Include="UnionTests.cs" /> <Compile Include="WhereTests.cs" /> <Compile Include="ZipTests.cs" /> + <Compile Include="$(CommonTestPath)\System\AssertExtensions.cs"> + <Link>Common\System\AssertExtensions.cs</Link> + </Compile> <Compile Include="$(CommonTestPath)\System\Diagnostics\DebuggerAttributes.cs"> <Link>Common\System\Diagnostics\DebuggerAttributes.cs</Link> </Compile> diff --git a/src/System.Linq/tests/TakeTests.cs b/src/System.Linq/tests/TakeTests.cs index 6ceb19e23b..1e72dbe5e4 100644 --- a/src/System.Linq/tests/TakeTests.cs +++ b/src/System.Linq/tests/TakeTests.cs @@ -179,7 +179,7 @@ namespace System.Linq.Tests public void ThrowsOnNullSource() { int[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.Take(5)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Take(5)); } [Fact] @@ -247,8 +247,8 @@ namespace System.Linq.Tests var taken = source.Take(3); Assert.Equal(1, taken.ElementAt(0)); Assert.Equal(3, taken.ElementAt(2)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => taken.ElementAt(-1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => taken.ElementAt(3)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => taken.ElementAt(-1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => taken.ElementAt(3)); } [Fact] @@ -258,8 +258,8 @@ namespace System.Linq.Tests var taken = source.Take(3); Assert.Equal(1, taken.ElementAt(0)); Assert.Equal(3, taken.ElementAt(2)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => taken.ElementAt(-1)); - Assert.Throws<ArgumentOutOfRangeException>("index", () => taken.ElementAt(3)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => taken.ElementAt(-1)); + AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => taken.ElementAt(3)); } [Fact] diff --git a/src/System.Linq/tests/TakeWhileTests.cs b/src/System.Linq/tests/TakeWhileTests.cs index 619859aa72..86d6b7981a 100644 --- a/src/System.Linq/tests/TakeWhileTests.cs +++ b/src/System.Linq/tests/TakeWhileTests.cs @@ -135,7 +135,7 @@ namespace System.Linq.Tests public void ThrowsOnNullSource() { int[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.TakeWhile(x => true)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.TakeWhile(x => true)); } [Fact] @@ -144,14 +144,14 @@ namespace System.Linq.Tests int[] source = { 1, 2, 3 }; Func<int, bool> nullPredicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => source.TakeWhile(nullPredicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => source.TakeWhile(nullPredicate)); } [Fact] public void ThrowsOnNullSourceIndexed() { int[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.TakeWhile((x, i) => true)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.TakeWhile((x, i) => true)); } [Fact] @@ -160,7 +160,7 @@ namespace System.Linq.Tests int[] source = { 1, 2, 3 }; Func<int, int, bool> nullPredicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => source.TakeWhile(nullPredicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => source.TakeWhile(nullPredicate)); } [Fact] diff --git a/src/System.Linq/tests/ThenByDescendingTests.cs b/src/System.Linq/tests/ThenByDescendingTests.cs index 4dd504c6c4..0610faa7a2 100644 --- a/src/System.Linq/tests/ThenByDescendingTests.cs +++ b/src/System.Linq/tests/ThenByDescendingTests.cs @@ -142,28 +142,28 @@ And Immortality.".Split(new[] { ' ', '\n', '\r', '—' }, StringSplitOptions.Rem public void NullSource() { IOrderedEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ThenByDescending(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ThenByDescending(i => i)); } [Fact] public void NullKeySelector() { Func<DateTime, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(e => e).ThenByDescending(keySelector)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(e => e).ThenByDescending(keySelector)); } [Fact] public void NullSourceComparer() { IOrderedEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ThenByDescending(i => i, null)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ThenByDescending(i => i, null)); } [Fact] public void NullKeySelectorComparer() { Func<DateTime, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(e => e).ThenByDescending(keySelector, null)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(e => e).ThenByDescending(keySelector, null)); } } } diff --git a/src/System.Linq/tests/ThenByTests.cs b/src/System.Linq/tests/ThenByTests.cs index e4c682b5ab..6b9955a805 100644 --- a/src/System.Linq/tests/ThenByTests.cs +++ b/src/System.Linq/tests/ThenByTests.cs @@ -147,28 +147,28 @@ And Immortality.".Split(new[] { ' ', '\n', '\r', '—' }, StringSplitOptions.Rem public void NullSource() { IOrderedEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ThenBy(i => i)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ThenBy(i => i)); } [Fact] public void NullKeySelector() { Func<DateTime, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(e => e).ThenBy(keySelector)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(e => e).ThenBy(keySelector)); } [Fact] public void NullSourceComparer() { IOrderedEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ThenBy(i => i, null)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ThenBy(i => i, null)); } [Fact] public void NullKeySelectorComparer() { Func<DateTime, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(e => e).ThenBy(keySelector, null)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Empty<DateTime>().OrderBy(e => e).ThenBy(keySelector, null)); } } } diff --git a/src/System.Linq/tests/ToArrayTests.cs b/src/System.Linq/tests/ToArrayTests.cs index 4ee327cd8a..da956675dc 100644 --- a/src/System.Linq/tests/ToArrayTests.cs +++ b/src/System.Linq/tests/ToArrayTests.cs @@ -120,7 +120,7 @@ namespace System.Linq.Tests public void ToArray_ThrowArgumentNullExceptionWhenSourceIsNull() { int[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ToArray()); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ToArray()); } // Generally the optimal approach. Anything that breaks this should be confirmed as not harming performance. diff --git a/src/System.Linq/tests/ToDictionaryTests.cs b/src/System.Linq/tests/ToDictionaryTests.cs index 3202305eae..54dbb88ead 100644 --- a/src/System.Linq/tests/ToDictionaryTests.cs +++ b/src/System.Linq/tests/ToDictionaryTests.cs @@ -129,7 +129,7 @@ namespace System.Linq.Tests public void ToDictionary_ThrowArgumentNullExceptionWhenSourceIsNull() { int[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ToDictionary(key => key)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ToDictionary(key => key)); } @@ -138,7 +138,7 @@ namespace System.Linq.Tests { int[] source = new int[0]; Func<int, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => source.ToDictionary(keySelector)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => source.ToDictionary(keySelector)); } [Fact] @@ -147,14 +147,14 @@ namespace System.Linq.Tests int[] source = new int[0]; Func<int, int> keySelector = key => key; Func<int, int> valueSelector = null; - Assert.Throws<ArgumentNullException>("elementSelector", () => source.ToDictionary(keySelector, valueSelector)); + AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => source.ToDictionary(keySelector, valueSelector)); } [Fact] public void ToDictionary_ThrowArgumentNullExceptionWhenSourceIsNullElementSelector() { int[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ToDictionary(key => key, e => e)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ToDictionary(key => key, e => e)); } @@ -163,7 +163,7 @@ namespace System.Linq.Tests { int[] source = new int[0]; Func<int, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => source.ToDictionary(keySelector, e => e)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => source.ToDictionary(keySelector, e => e)); } [Fact] @@ -187,7 +187,7 @@ namespace System.Linq.Tests int[] source = new int[] { 1, 2, 3 }; Func<int, string> keySelector = key => null; - Assert.Throws<ArgumentNullException>("key", () => source.ToDictionary(keySelector)); + AssertExtensions.Throws<ArgumentNullException>("key", () => source.ToDictionary(keySelector)); } [Fact] @@ -233,7 +233,7 @@ namespace System.Linq.Tests new { Name = default(string), Score = 55 } }; - Assert.Throws<ArgumentNullException>("key", () => source.ToDictionary(e => e.Name)); + AssertExtensions.Throws<ArgumentNullException>("key", () => source.ToDictionary(e => e.Name)); } [Fact] @@ -255,7 +255,7 @@ namespace System.Linq.Tests new { Name = default(string), Score = 55 } }; - Assert.Throws<ArgumentNullException>("key", () => source.ToDictionary(e => e.Name, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("key", () => source.ToDictionary(e => e.Name, new AnagramEqualityComparer())); } [Fact] @@ -277,7 +277,7 @@ namespace System.Linq.Tests new { Name = default(string), Score = 55 } }; - Assert.Throws<ArgumentNullException>("key", () => source.ToDictionary(e => e.Name, e => e)); + AssertExtensions.Throws<ArgumentNullException>("key", () => source.ToDictionary(e => e.Name, e => e)); } [Fact] @@ -299,7 +299,7 @@ namespace System.Linq.Tests new { Name = default(string), Score = 55 } }; - Assert.Throws<ArgumentNullException>("key", () => source.ToDictionary(e => e.Name, e => e, new AnagramEqualityComparer())); + AssertExtensions.Throws<ArgumentNullException>("key", () => source.ToDictionary(e => e.Name, e => e, new AnagramEqualityComparer())); } [Fact] diff --git a/src/System.Linq/tests/ToListTests.cs b/src/System.Linq/tests/ToListTests.cs index f37419cefb..e9282ef23f 100644 --- a/src/System.Linq/tests/ToListTests.cs +++ b/src/System.Linq/tests/ToListTests.cs @@ -88,7 +88,7 @@ namespace System.Linq.Tests public void ToList_ThrowArgumentNullExceptionWhenSourceIsNull() { int[] source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ToList()); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ToList()); } // Generally the optimal approach. Anything that breaks this should be confirmed as not harming performance. diff --git a/src/System.Linq/tests/ToLookupTests.cs b/src/System.Linq/tests/ToLookupTests.cs index 663420df1d..9849ddbdf2 100644 --- a/src/System.Linq/tests/ToLookupTests.cs +++ b/src/System.Linq/tests/ToLookupTests.cs @@ -169,70 +169,70 @@ namespace System.Linq.Tests public void NullSource() { IEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ToLookup(i => i / 10)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ToLookup(i => i / 10)); } [Fact] public void NullSourceExplicitComparer() { IEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ToLookup(i => i / 10, EqualityComparer<int>.Default)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ToLookup(i => i / 10, EqualityComparer<int>.Default)); } [Fact] public void NullSourceElementSelector() { IEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ToLookup(i => i / 10, i => i + 2)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ToLookup(i => i / 10, i => i + 2)); } [Fact] public void NullSourceElementSelectorExplicitComparer() { IEnumerable<int> source = null; - Assert.Throws<ArgumentNullException>("source", () => source.ToLookup(i => i / 10, i => i + 2, EqualityComparer<int>.Default)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.ToLookup(i => i / 10, i => i + 2, EqualityComparer<int>.Default)); } [Fact] public void NullKeySelector() { Func<int, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Range(0, 1000).ToLookup(keySelector)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Range(0, 1000).ToLookup(keySelector)); } [Fact] public void NullKeySelectorExplicitComparer() { Func<int, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Range(0, 1000).ToLookup(keySelector, EqualityComparer<int>.Default)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Range(0, 1000).ToLookup(keySelector, EqualityComparer<int>.Default)); } [Fact] public void NullKeySelectorElementSelector() { Func<int, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Range(0, 1000).ToLookup(keySelector, i => i + 2)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Range(0, 1000).ToLookup(keySelector, i => i + 2)); } [Fact] public void NullKeySelectorElementSelectorExplicitComparer() { Func<int, int> keySelector = null; - Assert.Throws<ArgumentNullException>("keySelector", () => Enumerable.Range(0, 1000).ToLookup(keySelector, i => i + 2, EqualityComparer<int>.Default)); + AssertExtensions.Throws<ArgumentNullException>("keySelector", () => Enumerable.Range(0, 1000).ToLookup(keySelector, i => i + 2, EqualityComparer<int>.Default)); } [Fact] public void NullElementSelector() { Func<int, int> elementSelector = null; - Assert.Throws<ArgumentNullException>("elementSelector", () => Enumerable.Range(0, 1000).ToLookup(i => i / 10, elementSelector)); + AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => Enumerable.Range(0, 1000).ToLookup(i => i / 10, elementSelector)); } [Fact] public void NullElementSelectorExplicitComparer() { Func<int, int> elementSelector = null; - Assert.Throws<ArgumentNullException>("elementSelector", () => Enumerable.Range(0, 1000).ToLookup(i => i / 10, elementSelector, EqualityComparer<int>.Default)); + AssertExtensions.Throws<ArgumentNullException>("elementSelector", () => Enumerable.Range(0, 1000).ToLookup(i => i / 10, elementSelector, EqualityComparer<int>.Default)); } [Theory] diff --git a/src/System.Linq/tests/UnionTests.cs b/src/System.Linq/tests/UnionTests.cs index 804ef33ea5..ab8f085d08 100644 --- a/src/System.Linq/tests/UnionTests.cs +++ b/src/System.Linq/tests/UnionTests.cs @@ -118,7 +118,7 @@ namespace System.Linq.Tests string[] first = null; string[] second = { "ttaM", "Charlie", "Bbo" }; - var ane = Assert.Throws<ArgumentNullException>("first", () => first.Union(second, new AnagramEqualityComparer())); + var ane = AssertExtensions.Throws<ArgumentNullException>("first", () => first.Union(second, new AnagramEqualityComparer())); } [Fact] @@ -127,7 +127,7 @@ namespace System.Linq.Tests string[] first = { "Bob", "Robert", "Tim", "Matt", "miT" }; string[] second = null; - var ane = Assert.Throws<ArgumentNullException>("second", () => first.Union(second, new AnagramEqualityComparer())); + var ane = AssertExtensions.Throws<ArgumentNullException>("second", () => first.Union(second, new AnagramEqualityComparer())); } [Fact] @@ -136,7 +136,7 @@ namespace System.Linq.Tests string[] first = null; string[] second = { "ttaM", "Charlie", "Bbo" }; - var ane = Assert.Throws<ArgumentNullException>("first", () => first.Union(second)); + var ane = AssertExtensions.Throws<ArgumentNullException>("first", () => first.Union(second)); } [Fact] @@ -145,7 +145,7 @@ namespace System.Linq.Tests string[] first = { "Bob", "Robert", "Tim", "Matt", "miT" }; string[] second = null; - var ane = Assert.Throws<ArgumentNullException>("second", () => first.Union(second)); + var ane = AssertExtensions.Throws<ArgumentNullException>("second", () => first.Union(second)); } [Fact] diff --git a/src/System.Linq/tests/WhereTests.cs b/src/System.Linq/tests/WhereTests.cs index a04444f131..0f7fa2cf58 100644 --- a/src/System.Linq/tests/WhereTests.cs +++ b/src/System.Linq/tests/WhereTests.cs @@ -20,8 +20,8 @@ namespace System.Linq.Tests Func<int, bool> simplePredicate = (value) => true; Func<int, int, bool> complexPredicate = (value, index) => true; - Assert.Throws<ArgumentNullException>("source", () => source.Where(simplePredicate)); - Assert.Throws<ArgumentNullException>("source", () => source.Where(complexPredicate)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Where(simplePredicate)); + AssertExtensions.Throws<ArgumentNullException>("source", () => source.Where(complexPredicate)); } [Fact] @@ -31,8 +31,8 @@ namespace System.Linq.Tests Func<int, bool> simplePredicate = null; Func<int, int, bool> complexPredicate = null; - Assert.Throws<ArgumentNullException>("predicate", () => source.Where(simplePredicate)); - Assert.Throws<ArgumentNullException>("predicate", () => source.Where(complexPredicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => source.Where(simplePredicate)); + AssertExtensions.Throws<ArgumentNullException>("predicate", () => source.Where(complexPredicate)); } #endregion diff --git a/src/System.Linq/tests/ZipTests.cs b/src/System.Linq/tests/ZipTests.cs index ce0fbbd8cf..1d94dc155d 100644 --- a/src/System.Linq/tests/ZipTests.cs +++ b/src/System.Linq/tests/ZipTests.cs @@ -37,7 +37,7 @@ namespace System.Linq.Tests IEnumerable<int> first = null; IEnumerable<int> second = new int[] { 2, 5, 9 }; - Assert.Throws<ArgumentNullException>("first", () => first.Zip<int, int, int>(second, (x, y) => x + y)); + AssertExtensions.Throws<ArgumentNullException>("first", () => first.Zip<int, int, int>(second, (x, y) => x + y)); } [Fact] @@ -46,7 +46,7 @@ namespace System.Linq.Tests IEnumerable<int> first = new int[] { 1, 2, 3 }; IEnumerable<int> second = null; - Assert.Throws<ArgumentNullException>("second", () => first.Zip<int, int, int>(second, (x, y) => x + y)); + AssertExtensions.Throws<ArgumentNullException>("second", () => first.Zip<int, int, int>(second, (x, y) => x + y)); } [Fact] @@ -56,7 +56,7 @@ namespace System.Linq.Tests IEnumerable<int> second = new int[] { 2, 4, 6 }; Func<int, int, int> func = null; - Assert.Throws<ArgumentNullException>("resultSelector", () => first.Zip(second, func)); + AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => first.Zip(second, func)); } [Fact] |