Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit e72bbba

Browse files
committed
System.Linq: Avoid outputting to console in cast tests
Move to Assert.Throws() instead of catching the InvalidCastException so we don't output to the console in Helper for some of the tests.
1 parent a723067 commit e72bbba

File tree

3 files changed

+79
-443
lines changed

3 files changed

+79
-443
lines changed

src/System.Linq/tests/LegacyTests/AverageTests.cs

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -778,41 +778,13 @@ public void Test()
778778

779779
public class Average3f
780780
{
781+
[Fact]
781782
// Type: long, OverflowException is thrown by param sum
782-
public static int Test3f()
783+
public void Test()
783784
{
784785
long[] source = { Int64.MaxValue, Int64.MaxValue };
785-
Console.WriteLine("111");
786-
try
787-
{
788-
var actual = source.Average();
789-
Console.WriteLine("222");
790-
return 1;
791-
}
792-
catch (OverflowException)
793-
{
794-
Console.WriteLine("333");
795-
return 0;
796-
}
797786

798-
catch (Exception e)
799-
{
800-
Console.WriteLine("4444");
801-
Console.WriteLine(e);
802-
return 0;
803-
}
804-
}
805-
806-
807-
public static int Main()
808-
{
809-
return Test3f();
810-
}
811-
812-
[Fact]
813-
public void Test()
814-
{
815-
Assert.Equal(0, Main());
787+
Assert.Throws<OverflowException>(() => source.Average());
816788
}
817789
}
818790

0 commit comments

Comments
 (0)