diff --git a/src/TestFramework/MSTest.Core/GenericParameterHelper.cs b/src/TestFramework/MSTest.Core/GenericParameterHelper.cs index 4f8a8144f9..096c574c3e 100644 --- a/src/TestFramework/MSTest.Core/GenericParameterHelper.cs +++ b/src/TestFramework/MSTest.Core/GenericParameterHelper.cs @@ -24,6 +24,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting public class GenericParameterHelper : IComparable, IEnumerable { #region Private Fields + private static readonly Random Randomizer = new Random(); private int data; private IList ienumerableStore; @@ -40,8 +41,7 @@ public class GenericParameterHelper : IComparable, IEnumerable /// public GenericParameterHelper() { - Random randomizer = new Random(); - this.Data = randomizer.Next(); + this.Data = Randomizer.Next(); } /// diff --git a/test/UnitTests/MSTest.Core.Unit.Tests/GenericParameterHelperTests.cs b/test/UnitTests/MSTest.Core.Unit.Tests/GenericParameterHelperTests.cs index 11f6985964..39b620a3e3 100644 --- a/test/UnitTests/MSTest.Core.Unit.Tests/GenericParameterHelperTests.cs +++ b/test/UnitTests/MSTest.Core.Unit.Tests/GenericParameterHelperTests.cs @@ -29,6 +29,15 @@ public void TestInitialize() this.sut = new TestFrameworkV2.GenericParameterHelper(10); } + [TestFrameworkV1.TestMethod] + public void EqualsShouldReturnFalseIfEachObjectHasDefaultDataValue() + { + TestFrameworkV2.GenericParameterHelper firstObject = new TestFrameworkV2.GenericParameterHelper(); + TestFrameworkV2.GenericParameterHelper secondObject = new TestFrameworkV2.GenericParameterHelper(); + + TestFrameworkV1.Assert.IsFalse(firstObject.Equals(secondObject)); + } + [TestFrameworkV1.TestMethod] public void EqualsShouldReturnTrueIfTwoObjectHasSameDataValue() {