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

Commit 5693129

Browse files
committed
Add tests for InvalidDataException
Fills in our code coverage for the partial facade portion of this library. Additionally, if we pull more types out of mscorlib and into this partial facade, we can easily add tests to this project.
1 parent 4b4b862 commit 5693129

File tree

5 files changed

+628
-2
lines changed

5 files changed

+628
-2
lines changed

src/System.IO/System.IO.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.22726.0
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO", "src\System.IO.csproj", "{07390899-C8F6-4E83-A3A9-6867B8CB46A0}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Tests", "tests\System.IO.Tests.csproj", "{492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{07390899-C8F6-4E83-A3A9-6867B8CB46A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{07390899-C8F6-4E83-A3A9-6867B8CB46A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{07390899-C8F6-4E83-A3A9-6867B8CB46A0}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<OutputType>Library</OutputType>
8+
<RootNamespace>System.IO</RootNamespace>
9+
<AssemblyName>System.IO.Tests</AssemblyName>
10+
<RestorePackages>true</RestorePackages>
11+
<ProjectGuid>{492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02}</ProjectGuid>
12+
</PropertyGroup>
13+
<!-- Default configurations to help VS understand the configurations -->
14+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
16+
<ItemGroup>
17+
<Compile Include="System\IO\InvalidDataExceptionTests.cs" />
18+
</ItemGroup>
19+
<ItemGroup>
20+
<!-- Compile tests against the contract, but copy our local-built implementation for testing -->
21+
<ProjectReference Include="..\src\System.IO.csproj">
22+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
23+
<OutputItemType>Content</OutputItemType>
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
<Targets>Build;DebugSymbolsProjectOutputGroup</Targets>
26+
</ProjectReference>
27+
</ItemGroup>
28+
<ItemGroup>
29+
<None Include="project.json" />
30+
</ItemGroup>
31+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
32+
</Project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using Xunit;
5+
6+
namespace System.IO
7+
{
8+
public static class InvalidDataExceptionTests
9+
{
10+
[Fact]
11+
public static void DefaultConstructor()
12+
{
13+
InvalidDataException ide = new InvalidDataException();
14+
15+
Assert.NotNull(ide.Message);
16+
}
17+
18+
[Fact]
19+
public static void MessageConstructor()
20+
{
21+
string message = "MessageConstructor";
22+
InvalidDataException ide = new InvalidDataException(message);
23+
24+
Assert.Equal(message, ide.Message);
25+
}
26+
27+
[Fact]
28+
public static void MessageInnerExceptionConstructor()
29+
{
30+
string message = "MessageConstructor";
31+
Exception innerException = new Exception();
32+
InvalidDataException ide = new InvalidDataException(message, innerException);
33+
34+
Assert.Equal(message, ide.Message);
35+
Assert.Same(innerException, ide.InnerException);
36+
}
37+
}
38+
}

src/System.IO/tests/project.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"dependencies": {
3+
"System.IO": "4.0.10-beta-*",
4+
"xunit": "2.0.0-beta5-build2785",
5+
"xunit.abstractions.netcore": "1.0.0-prerelease",
6+
"xunit.assert": "2.0.0-beta5-build2785",
7+
"xunit.core.netcore": "1.0.1-prerelease",
8+
"xunit.netcore.extensions": "1.0.0-prerelease-*"
9+
},
10+
"frameworks": {
11+
"dnxcore50": {}
12+
}
13+
}

0 commit comments

Comments
 (0)