Skip to content

Commit a782902

Browse files
committed
Tests added.
1 parent e889bd0 commit a782902

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

Platform.Threading.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29020.237
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Platform.Threading", "csharp\Platform.Threading\Platform.Threading.csproj", "{F7E3F718-E566-4358-9958-CF0E5730B6A6}"
77
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Platform.Threading.Tests", "csharp\Platform.Threading.Tests\Platform.Threading.Tests.csproj", "{0DA6066D-905B-4045-89E8-51C857891DE4}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{F7E3F718-E566-4358-9958-CF0E5730B6A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{F7E3F718-E566-4358-9958-CF0E5730B6A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{F7E3F718-E566-4358-9958-CF0E5730B6A6}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{0DA6066D-905B-4045-89E8-51C857891DE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{0DA6066D-905B-4045-89E8-51C857891DE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{0DA6066D-905B-4045-89E8-51C857891DE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{0DA6066D-905B-4045-89E8-51C857891DE4}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net472;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
5+
<IsPackable>false</IsPackable>
6+
<LangVersion>latest</LangVersion>
7+
</PropertyGroup>
8+
9+
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
10+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
15+
<PackageReference Include="xunit" Version="2.4.1" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" PrivateAssets="All" />
17+
<PackageReference Include="coverlet.collector" Version="1.2.0" PrivateAssets="All" />
18+
</ItemGroup>
19+
<ItemGroup>
20+
<ProjectReference Include="..\Platform.Threading\Platform.Threading.csproj" />
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Xunit;
2+
3+
namespace Platform.Threading.Tests
4+
{
5+
public class ThreadHelpersTests
6+
{
7+
[Fact]
8+
public void InvokeTest()
9+
{
10+
var number = 0;
11+
ThreadHelpers.InvokeWithExtendedMaxStackSize(() => number = 1);
12+
Assert.Equal(1, number);
13+
ThreadHelpers.InvokeWithExtendedMaxStackSize(2, (param) => number = (int)param);
14+
Assert.Equal(2, number);
15+
ThreadHelpers.InvokeWithModifiedMaxStackSize(() => number = 1, maxStackSize: 512);
16+
Assert.Equal(1, number);
17+
ThreadHelpers.InvokeWithModifiedMaxStackSize(2, (param) => number = (int)param, maxStackSize: 512);
18+
Assert.Equal(2, number);
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)