Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Adding Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
joperezr committed Nov 11, 2020
1 parent 44eaf59 commit e2b37db
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Microsoft.Bcl.HashCode/tests/Configurations.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project DefaultTargets="Build">
<PropertyGroup>
<BuildConfigurations>
netfx;
</BuildConfigurations>
</PropertyGroup>
</Project>
39 changes: 39 additions & 0 deletions src/Microsoft.Bcl.HashCode/tests/HashCodeSeedInitializerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.DotNet.RemoteExecutor;
using System;
using System.Reflection;
using Xunit;

namespace Microsoft.Bcl.HashCode.Tests
{
public class HashCodeSeedInitializerTests
{
[Fact]
public void EnsureSeedReturnsDifferentValuesTest()
{
var executor1 = RemoteExecutor.Invoke(GetHashCodeSeed, new RemoteInvokeOptions() { CheckExitCode = false });

int FirstSeed = executor1.ExitCode;
executor1.Dispose();

var executor2 = RemoteExecutor.Invoke(GetHashCodeSeed, new RemoteInvokeOptions() { CheckExitCode = false });

int SecondSeed = executor2.ExitCode;
executor2.Dispose();

Assert.NotEqual(FirstSeed, SecondSeed);

int GetHashCodeSeed()
{
var seed1Field = typeof(System.HashCode).GetField("s_seed", BindingFlags.NonPublic | BindingFlags.Static);
int returnCode = (int)((uint)seed1Field.GetValue(null));
return returnCode;
};
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>netfx-Debug;netfx-Release</Configurations>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
</PropertyGroup>
<ItemGroup>
<Compile Include="HashCodeSeedInitializerTests.cs" />
</ItemGroup>
</Project>

0 comments on commit e2b37db

Please sign in to comment.