diff options
author | vitek-karas <vitek.karas@microsoft.com> | 2018-09-13 13:32:32 -0700 |
---|---|---|
committer | vitek-karas <vitek.karas@microsoft.com> | 2018-09-13 13:32:32 -0700 |
commit | 109af65c23873c607b1746c3eede5f203eba3dd3 (patch) | |
tree | 277d4c18b7fbd7f582ace3f65f3c80f15a467d3e /tests/src | |
parent | 5699a504640a322935f7f57f3ea627cee494c804 (diff) | |
download | coreclr-109af65c23873c607b1746c3eede5f203eba3dd3.tar.gz coreclr-109af65c23873c607b1746c3eede5f203eba3dd3.tar.bz2 coreclr-109af65c23873c607b1746c3eede5f203eba3dd3.zip |
Move Assert class from Interop into the CoreCLRTestLibrary
Moving the Assert class to the common library so that it can be used
by tests outside of the Interop tree.
Diffstat (limited to 'tests/src')
30 files changed, 23 insertions, 33 deletions
diff --git a/tests/src/Interop/common/Assertion.cs b/tests/src/Common/CoreCLRTestLibrary/Assertion.cs index 4a7bd63732..e4f785a461 100644 --- a/tests/src/Interop/common/Assertion.cs +++ b/tests/src/Common/CoreCLRTestLibrary/Assertion.cs @@ -8,14 +8,14 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -namespace CoreFXTestLibrary +namespace TestLibrary { /// <summary> /// A collection of helper classes to test various conditions within /// unit tests. If the condition being tested is not met, an exception /// is thrown. /// </summary> - internal static class Assert + public static class Assert { /// <summary> /// Asserts that the given delegate throws an <see cref="ArgumentNullException"/> with the given parameter name. @@ -771,7 +771,7 @@ namespace CoreFXTestLibrary /// <summary> /// Exception raised by the Assert on Fail /// </summary> - internal class AssertTestException : Exception + public class AssertTestException : Exception { public AssertTestException(string message) : base(message) @@ -784,7 +784,7 @@ namespace CoreFXTestLibrary } } - internal static class ExceptionAssert + public static class ExceptionAssert { public static void Throws<T>(String message, Action a) where T : Exception { @@ -796,7 +796,7 @@ namespace CoreFXTestLibrary /// Specifies whether <see cref="Assert.Throws{T}"/> should require an exact type match when comparing the expected exception type with the thrown exception. /// </summary> [Flags] - internal enum AssertThrowsOptions + public enum AssertThrowsOptions { /// <summary> /// Specifies that <see cref="Assert.Throws{T}"/> should require an exact type diff --git a/tests/src/Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj b/tests/src/Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj index fc6226fe31..7e210d0749 100644 --- a/tests/src/Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj +++ b/tests/src/Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj @@ -26,6 +26,7 @@ </CodeAnalysisDependentAssemblyPaths> </ItemGroup> <ItemGroup> + <Compile Include="Assertion.cs" /> <Compile Include="Generator.cs" /> <Compile Include="Logging.cs" /> <Compile Include="TestFramework.cs" /> diff --git a/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValTest.cs b/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValTest.cs index 7bad4d302e..5c8daff0be 100644 --- a/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValTest.cs +++ b/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValTest.cs @@ -9,7 +9,7 @@ class TestHelper { public static void Assert(bool exp,string msg="") { - CoreFXTestLibrary.Assert.IsTrue(exp, msg); + TestLibrary.Assert.IsTrue(exp, msg); } } diff --git a/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValTest.csproj b/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValTest.csproj index cb68120e25..9541318485 100644 --- a/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValTest.csproj +++ b/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValTest.csproj @@ -25,7 +25,6 @@ </ItemGroup> <ItemGroup> <Compile Include="MarshalArrayByValTest.cs" /> - <Compile Include="..\..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/BestFitMapping/BestFitMapping.csproj b/tests/src/Interop/BestFitMapping/BestFitMapping.csproj index 5e33afde8e..055b49e1f5 100755 --- a/tests/src/Interop/BestFitMapping/BestFitMapping.csproj +++ b/tests/src/Interop/BestFitMapping/BestFitMapping.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/COM/Activator/Program.cs b/tests/src/Interop/COM/Activator/Program.cs index 117d55fa70..4316736950 100644 --- a/tests/src/Interop/COM/Activator/Program.cs +++ b/tests/src/Interop/COM/Activator/Program.cs @@ -7,7 +7,7 @@ namespace Activator using System; using System.Runtime.InteropServices; - using CoreFXTestLibrary; + using TestLibrary; using Console = Internal.Console; diff --git a/tests/src/Interop/COM/NETClients/Primitives/ArrayTests.cs b/tests/src/Interop/COM/NETClients/Primitives/ArrayTests.cs index 1881263242..74753b32bd 100644 --- a/tests/src/Interop/COM/NETClients/Primitives/ArrayTests.cs +++ b/tests/src/Interop/COM/NETClients/Primitives/ArrayTests.cs @@ -4,10 +4,10 @@ namespace NetClient { - using CoreFXTestLibrary; using System; using System.Collections.Generic; using System.Linq; + using TestLibrary; class ArrayTests { diff --git a/tests/src/Interop/COM/NETClients/Primitives/ErrorTests.cs b/tests/src/Interop/COM/NETClients/Primitives/ErrorTests.cs index 9694333b54..93eba8ef72 100644 --- a/tests/src/Interop/COM/NETClients/Primitives/ErrorTests.cs +++ b/tests/src/Interop/COM/NETClients/Primitives/ErrorTests.cs @@ -4,9 +4,9 @@ namespace NetClient { - using CoreFXTestLibrary; using System; using System.Runtime.InteropServices; + using TestLibrary; class ErrorTests { diff --git a/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitives.csproj b/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitives.csproj index 56d18ef73e..5cbfe1d75b 100644 --- a/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitives.csproj +++ b/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitives.csproj @@ -29,10 +29,10 @@ <Compile Include="../../ServerContracts/Primitives.cs" /> <Compile Include="../../ServerContracts/PrimitivesNativeServer.cs" /> <Compile Include="../../ServerContracts/ServerGuids.cs" /> - <Compile Include="../../../common/Assertion.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="../../NativeServer/CMakeLists.txt" /> + <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> </Project> diff --git a/tests/src/Interop/COM/NETClients/Primitives/NumericTests.cs b/tests/src/Interop/COM/NETClients/Primitives/NumericTests.cs index cff69ec197..e184d0d722 100644 --- a/tests/src/Interop/COM/NETClients/Primitives/NumericTests.cs +++ b/tests/src/Interop/COM/NETClients/Primitives/NumericTests.cs @@ -4,8 +4,8 @@ namespace NetClient { - using CoreFXTestLibrary; using System; + using TestLibrary; class NumericTests { diff --git a/tests/src/Interop/COM/NETClients/Primitives/StringTests.cs b/tests/src/Interop/COM/NETClients/Primitives/StringTests.cs index ab5271fd73..46cd5d9701 100644 --- a/tests/src/Interop/COM/NETClients/Primitives/StringTests.cs +++ b/tests/src/Interop/COM/NETClients/Primitives/StringTests.cs @@ -4,12 +4,12 @@ namespace NetClient { - using CoreFXTestLibrary; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; + using TestLibrary; class StringTests { diff --git a/tests/src/Interop/COM/NativeClients/Primitives.csproj b/tests/src/Interop/COM/NativeClients/Primitives.csproj index b1bc0e656c..ff06eccfc5 100644 --- a/tests/src/Interop/COM/NativeClients/Primitives.csproj +++ b/tests/src/Interop/COM/NativeClients/Primitives.csproj @@ -3,7 +3,7 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" /> <PropertyGroup> - <IgnoreInteropAssertionFile>true</IgnoreInteropAssertionFile> + <IgnoreCoreCLRTestLibraryDependency>true</IgnoreCoreCLRTestLibraryDependency> <CLRTestScriptLocalCoreShim>true</CLRTestScriptLocalCoreShim> </PropertyGroup> <ItemGroup> diff --git a/tests/src/Interop/DllImportAttribute/FileExtensionProbe.csproj b/tests/src/Interop/DllImportAttribute/FileExtensionProbe.csproj index 3127984d5c..d01e35503d 100644 --- a/tests/src/Interop/DllImportAttribute/FileExtensionProbe.csproj +++ b/tests/src/Interop/DllImportAttribute/FileExtensionProbe.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParam.csproj b/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParam.csproj index 3ffe378872..1a2d612d7e 100644 --- a/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParam.csproj +++ b/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParam.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/Interop.settings.targets b/tests/src/Interop/Interop.settings.targets index df05c154b0..f305111d32 100644 --- a/tests/src/Interop/Interop.settings.targets +++ b/tests/src/Interop/Interop.settings.targets @@ -10,6 +10,11 @@ <!-- Required source files --> <ItemGroup> - <Compile Condition="'$(IgnoreInteropAssertionFile)' != 'true'" Include="$(InteropCommonDir)Assertion.cs"/> + <ProjectReference + Condition="('$(IgnoreCoreCLRTestLibraryDependency)' != 'true') And ('$(ReferenceSystemPrivateCoreLib)' != 'true')" + Include="$(MSBuildThisFileDirectory)\..\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj" /> + <Compile + Condition="('$(IgnoreCoreCLRTestLibraryDependency)' != 'true') And ('$(ReferenceSystemPrivateCoreLib)' == 'true')" + Include="$(MSBuildThisFileDirectory)\..\Common\CoreCLRTestLibrary\Assertion.cs" /> </ItemGroup> </Project> diff --git a/tests/src/Interop/MarshalAPI/FunctionPointer/FunctionPtrTest.csproj b/tests/src/Interop/MarshalAPI/FunctionPointer/FunctionPtrTest.csproj index fe86cd24ef..5288a429cb 100644 --- a/tests/src/Interop/MarshalAPI/FunctionPointer/FunctionPtrTest.csproj +++ b/tests/src/Interop/MarshalAPI/FunctionPointer/FunctionPtrTest.csproj @@ -25,7 +25,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.cs b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.cs index 5b5d8459b7..fee9d35992 100644 --- a/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.cs +++ b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.cs @@ -7,7 +7,7 @@ using System.Reflection; using System.Security; using System.Runtime.InteropServices; using System.Collections.Generic; -using CoreFXTestLibrary; +using TestLibrary; #pragma warning disable 618 diff --git a/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.csproj b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.csproj index 6615490757..ddcd2c3e5b 100644 --- a/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.csproj +++ b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownTest.csproj @@ -29,7 +29,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/NativeCallable/NativeCallableTest.csproj b/tests/src/Interop/NativeCallable/NativeCallableTest.csproj index af3e9af7d0..fd5c9db40d 100644 --- a/tests/src/Interop/NativeCallable/NativeCallableTest.csproj +++ b/tests/src/Interop/NativeCallable/NativeCallableTest.csproj @@ -27,11 +27,11 @@ </ItemGroup> <ItemGroup> <Compile Include="NativeCallableTest.cs" /> - <Compile Include="..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <!-- This is needed to make sure native binary gets installed in the right location --> <ProjectReference Include="CMakeLists.txt" /> + <ProjectReference Include="..\..\..\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj" /> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> </Project>
\ No newline at end of file diff --git a/tests/src/Interop/PrimitiveMarshalling/Bool/BoolTest.csproj b/tests/src/Interop/PrimitiveMarshalling/Bool/BoolTest.csproj index 80518af96d..70c6e7b62b 100644 --- a/tests/src/Interop/PrimitiveMarshalling/Bool/BoolTest.csproj +++ b/tests/src/Interop/PrimitiveMarshalling/Bool/BoolTest.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/EnumTest.csproj b/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/EnumTest.csproj index 47fd657627..bf5d46abe6 100644 --- a/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/EnumTest.csproj +++ b/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/EnumTest.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/PrimitiveMarshalling/UIntPtr/PInvokeUIntPtrTest.csproj b/tests/src/Interop/PrimitiveMarshalling/UIntPtr/PInvokeUIntPtrTest.csproj index b731504fbf..79a3055776 100644 --- a/tests/src/Interop/PrimitiveMarshalling/UIntPtr/PInvokeUIntPtrTest.csproj +++ b/tests/src/Interop/PrimitiveMarshalling/UIntPtr/PInvokeUIntPtrTest.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="PInvokeUIntPtrTest.cs" /> - <Compile Include="..\..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/ReadMe.md b/tests/src/Interop/ReadMe.md index 4f400ea2ea..9bd1d79313 100644 --- a/tests/src/Interop/ReadMe.md +++ b/tests/src/Interop/ReadMe.md @@ -10,7 +10,7 @@ There should be no more than **1** project type per folder (i.e. a folder can co Ancillary source assets for all tests should be located in `Interop/common` and can be easily added to all managed tests via the `Interop.settings.targets` file or native tests via `Interop.cmake`. -A common pattern for testing is using the `Assert` utilities found in the `CoreFX` repo. A copy of some of these utilities can be found at `Interop/common/Assertion.cs` and is included in all test projects by the `Interop.settings.targets` import. In order to use, add the following `using CoreFXTestLibrary;` in the relevant test file. +A common pattern for testing is using the `Assert` utilities found in the `CoreFX` repo. This class is part of the `CoreCLRTestLibrary` which is included in all test projects by the `Interop.settings.targets` import. In order to use, add the following `using TestLibrary;` in the relevant test file. ### Managed diff --git a/tests/src/Interop/RefCharArray/RefCharArrayTest.csproj b/tests/src/Interop/RefCharArray/RefCharArrayTest.csproj index 0f9075decc..d4f9f1f845 100644 --- a/tests/src/Interop/RefCharArray/RefCharArrayTest.csproj +++ b/tests/src/Interop/RefCharArray/RefCharArrayTest.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/RefInt/RefIntTest.csproj b/tests/src/Interop/RefInt/RefIntTest.csproj index 289d89b3d2..7b38bb9b92 100644 --- a/tests/src/Interop/RefInt/RefIntTest.csproj +++ b/tests/src/Interop/RefInt/RefIntTest.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/SimpleStruct/SimpleStruct.csproj b/tests/src/Interop/SimpleStruct/SimpleStruct.csproj index 034f1b6e64..5403856a95 100644 --- a/tests/src/Interop/SimpleStruct/SimpleStruct.csproj +++ b/tests/src/Interop/SimpleStruct/SimpleStruct.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/SizeConst/SizeConstTest.csproj b/tests/src/Interop/SizeConst/SizeConstTest.csproj index d8718bd907..fe69dfe260 100644 --- a/tests/src/Interop/SizeConst/SizeConstTest.csproj +++ b/tests/src/Interop/SizeConst/SizeConstTest.csproj @@ -27,7 +27,6 @@ </ItemGroup> <ItemGroup> <Compile Include="SizeConstTest.cs" /> - <Compile Include="..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj index d78ecb19e6..5212af84ac 100644 --- a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj +++ b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj @@ -25,7 +25,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTest.csproj b/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTest.csproj index 017228b224..0da25d09b6 100644 --- a/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTest.csproj +++ b/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTest.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> diff --git a/tests/src/Interop/StringMarshalling/UTF8/UTF8Test.csproj b/tests/src/Interop/StringMarshalling/UTF8/UTF8Test.csproj index 9ecc96517f..b88214cdf3 100644 --- a/tests/src/Interop/StringMarshalling/UTF8/UTF8Test.csproj +++ b/tests/src/Interop/StringMarshalling/UTF8/UTF8Test.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> <Compile Include="*.cs" /> - <Compile Include="..\..\common\Assertion.cs" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |