From e3d6e822df12fed112a9c68311a11fac8a4cf914 Mon Sep 17 00:00:00 2001 From: Abhitej John Date: Wed, 12 Jul 2017 13:26:18 +0530 Subject: [PATCH] Making all assert ctor's private and the classes sealed. We want users to extend from Assert.That instead and not by creating instances of the Assert class which does not have any instance methods. (#224) --- src/TestFramework/MSTest.Core/Assertions/Assert.cs | 6 +++++- .../MSTest.Core/Assertions/CollectionAssert.cs | 6 +++++- src/TestFramework/MSTest.Core/Assertions/StringAssert.cs | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/TestFramework/MSTest.Core/Assertions/Assert.cs b/src/TestFramework/MSTest.Core/Assertions/Assert.cs index f930e80377..5e620a3919 100644 --- a/src/TestFramework/MSTest.Core/Assertions/Assert.cs +++ b/src/TestFramework/MSTest.Core/Assertions/Assert.cs @@ -14,12 +14,16 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting /// unit tests. If the condition being tested is not met, an exception /// is thrown. /// - public class Assert + public sealed class Assert { private static Assert that; #region Singleton constructor + private Assert() + { + } + /// /// Gets the singleton instance of the Assert functionality. /// diff --git a/src/TestFramework/MSTest.Core/Assertions/CollectionAssert.cs b/src/TestFramework/MSTest.Core/Assertions/CollectionAssert.cs index a5e8a3535c..8388761be7 100644 --- a/src/TestFramework/MSTest.Core/Assertions/CollectionAssert.cs +++ b/src/TestFramework/MSTest.Core/Assertions/CollectionAssert.cs @@ -15,12 +15,16 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting /// with collections within unit tests. If the condition being tested is not /// met, an exception is thrown. /// - public class CollectionAssert + public sealed class CollectionAssert { private static CollectionAssert that; #region Singleton constructor + private CollectionAssert() + { + } + /// /// Gets the singleton instance of the CollectionAssert functionality. /// diff --git a/src/TestFramework/MSTest.Core/Assertions/StringAssert.cs b/src/TestFramework/MSTest.Core/Assertions/StringAssert.cs index e0f3b5763f..e419efe17b 100644 --- a/src/TestFramework/MSTest.Core/Assertions/StringAssert.cs +++ b/src/TestFramework/MSTest.Core/Assertions/StringAssert.cs @@ -10,12 +10,16 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting /// /// The string assert. /// - public class StringAssert + public sealed class StringAssert { private static StringAssert that; #region Singleton constructor + private StringAssert() + { + } + /// /// Gets the singleton instance of the CollectionAssert functionality. ///