зеркало из https://github.com/microsoft/testfx.git
Added stylecop and made fixes to framework and its unit test. (#72)
Will add for the remaining projects next.
This commit is contained in:
Родитель
71fd9dddbb
Коммит
bdba212cd3
|
@ -85,6 +85,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Universal", "Universal", "{
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{929A3EDE-893B-4801-82BA-01FD947291CB}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
scripts\build\stylecop.json = scripts\build\stylecop.json
|
||||
scripts\build\stylecop.ruleset = scripts\build\stylecop.ruleset
|
||||
scripts\build\stylecop.test.ruleset = scripts\build\stylecop.test.ruleset
|
||||
Nuget.config = Nuget.config
|
||||
scripts\build\TestFx.Loc.targets = scripts\build\TestFx.Loc.targets
|
||||
scripts\build\TestFx.Settings.targets = scripts\build\TestFx.Settings.targets
|
||||
|
|
|
@ -29,4 +29,11 @@
|
|||
<LciRoot>$(TestFxRoot)\loc\lci</LciRoot>
|
||||
<IsTest Condition="$(MSBuildProjectDirectory.Contains('\test\'))">true</IsTest>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Code analysis settings -->
|
||||
<PropertyGroup>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<CodeAnalysisRuleSet>$(TestFxRoot)scripts/build/stylecop.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet Condition="$(IsTest) == 'true'">$(TestFxRoot)scripts/build/stylecop.test.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -14,6 +14,13 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Including dependencies for StyleCop. -->
|
||||
<ItemGroup Condition="$(ShouldEnableStyleCop) == 'true'">
|
||||
<Analyzer Include="$(TestFxRoot)packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
|
||||
<Analyzer Include="$(TestFxRoot)packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
|
||||
<Analyzer Include="$(TestFxRoot)packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$(IsTest) == '' or $(IsTest) == 'false'">
|
||||
<FilesToSign Include="$(OutDir)\$(AssemblyName).dll" Condition="'$(IsVsixProj)' == '' or '$(IsVsixProj)' != 'true'">
|
||||
<Authenticode>Microsoft</Authenticode>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
||||
"settings": {
|
||||
"documentationRules": {
|
||||
"companyName": "Microsoft Corporation",
|
||||
"copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the MIT license. See LICENSE file in the project root for full license information.",
|
||||
"xmlHeader": false,
|
||||
"fileNamingConvention": "metadata"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Rules for testFx source code" Description="Code analysis rules for src projects." ToolsVersion="14.0">
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
|
||||
<!-- Allow use of regions -->
|
||||
<Rule Id="SA1124" Action="None" />
|
||||
</Rules>
|
||||
</RuleSet>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Rules for testfx tests" Description="Code analysis rules for testFx test projects." ToolsVersion="14.0">
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
|
||||
<!-- XML documentation checks are not required for test projects -->
|
||||
<Rule Id="SA1652" Action="None" />
|
||||
|
||||
<!-- Allow use of regions -->
|
||||
<Rule Id="SA1124" Action="None" />
|
||||
|
||||
<!-- Allow use of multiple types defined in a single file -->
|
||||
<Rule Id="SA1402" Action="None" />
|
||||
</Rules>
|
||||
</RuleSet>
|
|
@ -1,136 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for Framework Exceptions.
|
||||
/// </summary>
|
||||
public abstract partial class UnitTestAssertException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UnitTestAssertException"/> class.
|
||||
/// </summary>
|
||||
protected UnitTestAssertException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UnitTestAssertException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
/// <param name="ex"> The exception. </param>
|
||||
protected UnitTestAssertException(string msg, Exception ex) : base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UnitTestAssertException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
protected UnitTestAssertException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AssertFailedException class. Used to indicate failure for a test case
|
||||
/// </summary>
|
||||
public partial class AssertFailedException : UnitTestAssertException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertFailedException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
/// <param name="ex"> The exception. </param>
|
||||
public AssertFailedException(string msg, Exception ex)
|
||||
: base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertFailedException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
public AssertFailedException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertFailedException"/> class.
|
||||
/// </summary>
|
||||
public AssertFailedException() : base()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The assert inconclusive exception.
|
||||
/// </summary>
|
||||
public partial class AssertInconclusiveException : UnitTestAssertException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertInconclusiveException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
/// <param name="ex"> The exception. </param>
|
||||
public AssertInconclusiveException(string msg, Exception ex)
|
||||
: base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertInconclusiveException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
public AssertInconclusiveException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertInconclusiveException"/> class.
|
||||
/// </summary>
|
||||
public AssertInconclusiveException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// InternalTestFailureException class. Used to indicate internal failure for a test case
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is only added to preserve source compatibility with the V1 framework.
|
||||
/// For all practical purposes either use AssertFailedException/AssertInconclusiveException.
|
||||
/// </remarks>
|
||||
public class InternalTestFailureException : UnitTestAssertException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InternalTestFailureException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The exception message. </param>
|
||||
/// <param name="ex"> The exception. </param>
|
||||
public InternalTestFailureException(string msg, Exception ex) : base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InternalTestFailureException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The exception message. </param>
|
||||
public InternalTestFailureException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InternalTestFailureException"/> class.
|
||||
/// </summary>
|
||||
public InternalTestFailureException() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -344,7 +344,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreSameGivenValues,
|
||||
message == null ? String.Empty : ReplaceNulls(message));
|
||||
message == null ? string.Empty : ReplaceNulls(message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,8 +447,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// The second value to compare. This is the value produced by the code under test.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual<T>(T expected, T actual)
|
||||
{
|
||||
|
@ -506,12 +505,12 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// An array of parameters to use when formatting <paramref name="message"/>.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual<T>(T expected, T actual, string message, params object[] parameters)
|
||||
{
|
||||
if (!Object.Equals(expected, actual))
|
||||
if (!object.Equals(expected, actual))
|
||||
{
|
||||
string finalMessage;
|
||||
if (actual != null && expected != null && !actual.GetType().Equals(expected.GetType()))
|
||||
|
@ -520,7 +519,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreEqualDifferentTypesFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
ReplaceNulls(expected),
|
||||
expected.GetType().FullName,
|
||||
ReplaceNulls(actual),
|
||||
|
@ -531,7 +530,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreEqualFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
ReplaceNulls(expected),
|
||||
ReplaceNulls(actual));
|
||||
}
|
||||
|
@ -619,12 +618,12 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// </exception>
|
||||
public static void AreNotEqual<T>(T notExpected, T actual, string message, params object[] parameters)
|
||||
{
|
||||
if (Object.Equals(notExpected, actual))
|
||||
if (object.Equals(notExpected, actual))
|
||||
{
|
||||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreNotEqualFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
ReplaceNulls(notExpected),
|
||||
ReplaceNulls(actual));
|
||||
HandleFail("Assert.AreNotEqual", finalMessage, parameters);
|
||||
|
@ -648,7 +647,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// </exception>
|
||||
public static void AreEqual(object expected, object actual)
|
||||
{
|
||||
AreEqual(expected, actual, String.Empty, null);
|
||||
AreEqual(expected, actual, string.Empty, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -864,7 +863,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreEqualDeltaFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
expected.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
actual.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
delta.ToString(CultureInfo.CurrentCulture.NumberFormat));
|
||||
|
@ -876,7 +875,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreEqualDeltaFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
expected.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
actual.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
delta.ToString(CultureInfo.CurrentCulture.NumberFormat));
|
||||
|
@ -971,7 +970,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
var finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreNotEqualDeltaFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
notExpected.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
actual.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
delta.ToString(CultureInfo.CurrentCulture.NumberFormat));
|
||||
|
@ -1024,8 +1023,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <paramref name="delta"/>. The message is shown in test results.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(double expected, double actual, double delta, string message)
|
||||
{
|
||||
|
@ -1056,8 +1054,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// An array of parameters to use when formatting <paramref name="message"/>.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(double expected, double actual, double delta, string message, params object[] parameters)
|
||||
{
|
||||
|
@ -1066,7 +1063,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreEqualDeltaFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
expected.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
actual.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
delta.ToString(CultureInfo.CurrentCulture.NumberFormat));
|
||||
|
@ -1078,7 +1075,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreEqualDeltaFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
expected.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
actual.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
delta.ToString(CultureInfo.CurrentCulture.NumberFormat));
|
||||
|
@ -1173,7 +1170,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreNotEqualDeltaFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
notExpected.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
actual.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
delta.ToString(CultureInfo.CurrentCulture.NumberFormat));
|
||||
|
@ -1196,8 +1193,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// indicates a case-insensitive comparison.)
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(string expected, string actual, bool ignoreCase)
|
||||
{
|
||||
|
@ -1224,8 +1220,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// test results.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(string expected, string actual, bool ignoreCase, string message)
|
||||
{
|
||||
|
@ -1255,8 +1250,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// An array of parameters to use when formatting <paramref name="message"/>.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(string expected, string actual, bool ignoreCase, string message, params object[] parameters)
|
||||
{
|
||||
|
@ -1281,8 +1275,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// A CultureInfo object that supplies culture-specific comparison information.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(string expected, string actual, bool ignoreCase, CultureInfo culture)
|
||||
{
|
||||
|
@ -1312,8 +1305,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// test results.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(string expected, string actual, bool ignoreCase, CultureInfo culture, string message)
|
||||
{
|
||||
|
@ -1346,24 +1338,23 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// An array of parameters to use when formatting <paramref name="message"/>.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(string expected, string actual, bool ignoreCase, CultureInfo culture, string message, params object[] parameters)
|
||||
{
|
||||
CheckParameterNotNull(culture, "Assert.AreEqual", "culture", string.Empty);
|
||||
if (0 != CompareInternal(expected, actual, ignoreCase, culture))
|
||||
if (CompareInternal(expected, actual, ignoreCase, culture) != 0)
|
||||
{
|
||||
string finalMessage;
|
||||
|
||||
// Comparison failed. Check if it was a case-only failure.
|
||||
if (!ignoreCase &&
|
||||
0 == CompareInternal(expected, actual, ignoreCase, culture))
|
||||
CompareInternal(expected, actual, ignoreCase, culture) == 0)
|
||||
{
|
||||
finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreEqualCaseFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
ReplaceNulls(expected),
|
||||
ReplaceNulls(actual));
|
||||
}
|
||||
|
@ -1372,7 +1363,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreEqualFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
ReplaceNulls(expected),
|
||||
ReplaceNulls(actual));
|
||||
}
|
||||
|
@ -1552,12 +1543,12 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public static void AreNotEqual(string notExpected, string actual, bool ignoreCase, CultureInfo culture, string message, params object[] parameters)
|
||||
{
|
||||
CheckParameterNotNull(culture, "Assert.AreNotEqual", "culture", string.Empty);
|
||||
if (0 == CompareInternal(notExpected, actual, ignoreCase, culture))
|
||||
if (CompareInternal(notExpected, actual, ignoreCase, culture) == 0)
|
||||
{
|
||||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AreNotEqualFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
ReplaceNulls(notExpected),
|
||||
ReplaceNulls(actual));
|
||||
HandleFail("Assert.AreNotEqual", finalMessage, parameters);
|
||||
|
@ -1653,7 +1644,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.IsInstanceOfFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
expectedType.ToString(),
|
||||
value.GetType().ToString());
|
||||
HandleFail("Assert.IsInstanceOfType", finalMessage, parameters);
|
||||
|
@ -1745,7 +1736,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.IsNotInstanceOfFailMsg,
|
||||
message == null ? String.Empty : ReplaceNulls(message),
|
||||
message == null ? string.Empty : ReplaceNulls(message),
|
||||
wrongType.ToString(),
|
||||
value.GetType().ToString());
|
||||
HandleFail("Assert.IsNotInstanceOfType", finalMessage, parameters);
|
||||
|
@ -1887,7 +1878,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
|
||||
/// <summary>
|
||||
/// Tests whether the code specified by delegate <paramref name="action"/> throws exact given exception of type <typeparamref name="T"/> (and not of derived type)
|
||||
/// and throws
|
||||
/// and throws
|
||||
/// <code>
|
||||
/// AssertFailedException
|
||||
/// </code>
|
||||
|
@ -1905,14 +1896,15 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <returns>
|
||||
/// The type of exception expected to be thrown.
|
||||
/// </returns>
|
||||
public static T ThrowsException<T>(Action action) where T : Exception
|
||||
public static T ThrowsException<T>(Action action)
|
||||
where T : Exception
|
||||
{
|
||||
return ThrowsException<T>(action, string.Empty, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the code specified by delegate <paramref name="action"/> throws exact given exception of type <typeparamref name="T"/> (and not of derived type)
|
||||
/// and throws
|
||||
/// and throws
|
||||
/// <code>
|
||||
/// AssertFailedException
|
||||
/// </code>
|
||||
|
@ -1934,14 +1926,15 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <returns>
|
||||
/// The type of exception expected to be thrown.
|
||||
/// </returns>
|
||||
public static T ThrowsException<T>(Action action, string message) where T : Exception
|
||||
public static T ThrowsException<T>(Action action, string message)
|
||||
where T : Exception
|
||||
{
|
||||
return ThrowsException<T>(action, message, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the code specified by delegate <paramref name="action"/> throws exact given exception of type <typeparamref name="T"/> (and not of derived type)
|
||||
/// and throws
|
||||
/// and throws
|
||||
/// <code>
|
||||
/// AssertFailedException
|
||||
/// </code>
|
||||
|
@ -1959,14 +1952,15 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <returns>
|
||||
/// The type of exception expected to be thrown.
|
||||
/// </returns>
|
||||
public static T ThrowsException<T>(Func<object> action) where T : Exception
|
||||
public static T ThrowsException<T>(Func<object> action)
|
||||
where T : Exception
|
||||
{
|
||||
return ThrowsException<T>(action, string.Empty, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the code specified by delegate <paramref name="action"/> throws exact given exception of type <typeparamref name="T"/> (and not of derived type)
|
||||
/// and throws
|
||||
/// and throws
|
||||
/// <code>
|
||||
/// AssertFailedException
|
||||
/// </code>
|
||||
|
@ -1988,14 +1982,15 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <returns>
|
||||
/// The type of exception expected to be thrown.
|
||||
/// </returns>
|
||||
public static T ThrowsException<T>(Func<object> action, string message) where T : Exception
|
||||
public static T ThrowsException<T>(Func<object> action, string message)
|
||||
where T : Exception
|
||||
{
|
||||
return ThrowsException<T>(action, message, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the code specified by delegate <paramref name="action"/> throws exact given exception of type <typeparamref name="T"/> (and not of derived type)
|
||||
/// and throws
|
||||
/// and throws
|
||||
/// <code>
|
||||
/// AssertFailedException
|
||||
/// </code>
|
||||
|
@ -2020,14 +2015,15 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <returns>
|
||||
/// The type of exception expected to be thrown.
|
||||
/// </returns>
|
||||
public static T ThrowsException<T>(Func<object> action, string message, params object[] parameters) where T : Exception
|
||||
public static T ThrowsException<T>(Func<object> action, string message, params object[] parameters)
|
||||
where T : Exception
|
||||
{
|
||||
return ThrowsException<T>(() => { action(); }, message, parameters);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the code specified by delegate <paramref name="action"/> throws exact given exception of type <typeparamref name="T"/> (and not of derived type)
|
||||
/// and throws
|
||||
/// and throws
|
||||
/// <code>
|
||||
/// AssertFailedException
|
||||
/// </code>
|
||||
|
@ -2052,9 +2048,9 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <returns>
|
||||
/// The type of exception expected to be thrown.
|
||||
/// </returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
|
||||
Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
|
||||
public static T ThrowsException<T>(Action action, string message, params object[] parameters) where T : Exception
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
|
||||
public static T ThrowsException<T>(Action action, string message, params object[] parameters)
|
||||
where T : Exception
|
||||
{
|
||||
var finalMessage = string.Empty;
|
||||
|
||||
|
@ -2103,7 +2099,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
|
||||
/// <summary>
|
||||
/// Tests whether the code specified by delegate <paramref name="action"/> throws exact given exception of type <typeparamref name="T"/> (and not of derived type)
|
||||
/// and throws
|
||||
/// and throws
|
||||
/// <code>
|
||||
/// AssertFailedException
|
||||
/// </code>
|
||||
|
@ -2121,7 +2117,8 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <returns>
|
||||
/// The <see cref="Task"/> executing the delegate.
|
||||
/// </returns>
|
||||
public static async Task<T> ThrowsExceptionAsync<T>(Func<Task> action) where T : Exception
|
||||
public static async Task<T> ThrowsExceptionAsync<T>(Func<Task> action)
|
||||
where T : Exception
|
||||
{
|
||||
return await ThrowsExceptionAsync<T>(action, string.Empty, null);
|
||||
}
|
||||
|
@ -2142,7 +2139,8 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <returns>
|
||||
/// The <see cref="Task"/> executing the delegate.
|
||||
/// </returns>
|
||||
public static async Task<T> ThrowsExceptionAsync<T>(Func<Task> action, string message) where T : Exception
|
||||
public static async Task<T> ThrowsExceptionAsync<T>(Func<Task> action, string message)
|
||||
where T : Exception
|
||||
{
|
||||
return await ThrowsExceptionAsync<T>(action, message, null);
|
||||
}
|
||||
|
@ -2166,7 +2164,8 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <returns>
|
||||
/// The <see cref="Task"/> executing the delegate.
|
||||
/// </returns>
|
||||
public static async Task<T> ThrowsExceptionAsync<T>(Func<Task> action, string message, params object[] parameters) where T : Exception
|
||||
public static async Task<T> ThrowsExceptionAsync<T>(Func<Task> action, string message, params object[] parameters)
|
||||
where T : Exception
|
||||
{
|
||||
var finalMessage = string.Empty;
|
||||
|
||||
|
@ -2213,7 +2212,6 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
@ -2309,7 +2307,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
internal static string ReplaceNulls(object input)
|
||||
{
|
||||
// Use the localized "(null)" string for null values.
|
||||
if (null == input)
|
||||
if (input == null)
|
||||
{
|
||||
return FrameworkMessages.Common_NullInMessages.ToString();
|
||||
}
|
||||
|
@ -2335,52 +2333,4 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The helper.
|
||||
/// </summary>
|
||||
internal static class Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// The check parameter not null.
|
||||
/// </summary>
|
||||
/// <param name="param">
|
||||
/// The parameter.
|
||||
/// </param>
|
||||
/// <param name="parameterName">
|
||||
/// The parameter name.
|
||||
/// </param>
|
||||
/// <param name="message">
|
||||
/// The message.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException"> Throws argument null exception when parameter is null. </exception>
|
||||
internal static void CheckParameterNotNull(object param, string parameterName, string message)
|
||||
{
|
||||
if (param == null)
|
||||
{
|
||||
throw new ArgumentNullException(parameterName, message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The check parameter not null or empty.
|
||||
/// </summary>
|
||||
/// <param name="param">
|
||||
/// The parameter.
|
||||
/// </param>
|
||||
/// <param name="parameterName">
|
||||
/// The parameter name.
|
||||
/// </param>
|
||||
/// <param name="message">
|
||||
/// The message.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentException"> Throws ArgumentException when parameter is null. </exception>
|
||||
internal static void CheckParameterNotNullOrEmpty(string param, string parameterName, string message)
|
||||
{
|
||||
if (string.IsNullOrEmpty(param))
|
||||
{
|
||||
throw new ArgumentException(parameterName, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,9 +16,9 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// met, an exception is thrown.
|
||||
/// </summary>
|
||||
public static class CollectionAssert
|
||||
{
|
||||
{
|
||||
#region Membership
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the specified collection contains the specified element
|
||||
/// and throws an exception if the element is not in the collection.
|
||||
|
@ -233,7 +233,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
Assert.CheckParameterNotNull(collection, "CollectionAssert.AllItemsAreNotNull", "collection", string.Empty);
|
||||
foreach (object current in collection)
|
||||
{
|
||||
if (null == current)
|
||||
if (current == null)
|
||||
{
|
||||
Assert.HandleFail("CollectionAssert.AllItemsAreNotNull", message, parameters);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
Dictionary<object, bool> table = new Dictionary<object, bool>();
|
||||
foreach (object current in collection)
|
||||
{
|
||||
if (null == current)
|
||||
if (current == null)
|
||||
{
|
||||
if (foundNull == false)
|
||||
{
|
||||
|
@ -318,9 +318,9 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
var finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AllItemsAreUniqueFailMsg,
|
||||
message == null ? String.Empty : message,
|
||||
message == null ? string.Empty : message,
|
||||
FrameworkMessages.Common_NullInMessages);
|
||||
|
||||
|
||||
Assert.HandleFail("CollectionAssert.AllItemsAreUnique", finalMessage, parameters);
|
||||
}
|
||||
}
|
||||
|
@ -331,20 +331,20 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.AllItemsAreUniqueFailMsg,
|
||||
message == null ? String.Empty : message,
|
||||
message == null ? string.Empty : message,
|
||||
Assert.ReplaceNulls(current));
|
||||
|
||||
Assert.HandleFail("CollectionAssert.AllItemsAreUnique", finalMessage, parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
table.Add(current, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Subset
|
||||
|
||||
|
@ -504,7 +504,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Equivalence
|
||||
|
||||
|
@ -527,7 +527,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// </exception>
|
||||
public static void AreEquivalent(ICollection expected, ICollection actual)
|
||||
{
|
||||
AreEquivalent(expected, actual, String.Empty, null);
|
||||
AreEquivalent(expected, actual, string.Empty, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -603,8 +603,8 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.ElementNumbersDontMatch,
|
||||
message == null ? String.Empty : Assert.ReplaceNulls(message),
|
||||
expected.Count,
|
||||
message == null ? string.Empty : Assert.ReplaceNulls(message),
|
||||
expected.Count,
|
||||
actual.Count);
|
||||
Assert.HandleFail("CollectionAssert.AreEquivalent", finalMessage, parameters);
|
||||
}
|
||||
|
@ -625,8 +625,8 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.ActualHasMismatchedElements,
|
||||
message == null ? string.Empty : Assert.ReplaceNulls(message),
|
||||
expectedCount.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
Assert.ReplaceNulls(mismatchedElement),
|
||||
expectedCount.ToString(CultureInfo.CurrentCulture.NumberFormat),
|
||||
Assert.ReplaceNulls(mismatchedElement),
|
||||
actualCount.ToString(CultureInfo.CurrentCulture.NumberFormat));
|
||||
Assert.HandleFail("CollectionAssert.AreEquivalent", finalMessage, parameters);
|
||||
}
|
||||
|
@ -723,7 +723,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
var finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.BothCollectionsSameReference,
|
||||
message == null ? String.Empty : Assert.ReplaceNulls(message));
|
||||
message == null ? string.Empty : Assert.ReplaceNulls(message));
|
||||
Assert.HandleFail("CollectionAssert.AreNotEquivalent", finalMessage, parameters);
|
||||
}
|
||||
|
||||
|
@ -739,7 +739,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
string finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.BothCollectionsEmpty,
|
||||
message == null ? String.Empty : Assert.ReplaceNulls(message));
|
||||
message == null ? string.Empty : Assert.ReplaceNulls(message));
|
||||
Assert.HandleFail("CollectionAssert.AreNotEquivalent", finalMessage, parameters);
|
||||
}
|
||||
|
||||
|
@ -756,8 +756,8 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
Assert.HandleFail("CollectionAssert.AreNotEquivalent", finalMessage, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Type
|
||||
|
||||
|
@ -849,9 +849,9 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
var finalMessage = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.ElementTypesAtIndexDontMatch,
|
||||
message == null ? String.Empty : Assert.ReplaceNulls(message),
|
||||
i,
|
||||
expectedType.ToString(),
|
||||
message == null ? string.Empty : Assert.ReplaceNulls(message),
|
||||
i,
|
||||
expectedType.ToString(),
|
||||
element.GetType().ToString());
|
||||
|
||||
Assert.HandleFail("CollectionAssert.AllItemsAreInstancesOfType", finalMessage, parameters);
|
||||
|
@ -860,7 +860,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region AreEqual
|
||||
|
@ -879,12 +879,12 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// code under test.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(ICollection expected, ICollection actual)
|
||||
{
|
||||
AreEqual(expected, actual, String.Empty, null);
|
||||
AreEqual(expected, actual, string.Empty, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -906,7 +906,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// test results.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(ICollection expected, ICollection actual, string message)
|
||||
|
@ -936,7 +936,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// An array of parameters to use when formatting <paramref name="message"/>.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(ICollection expected, ICollection actual, string message, params object[] parameters)
|
||||
|
@ -1048,12 +1048,12 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// The compare implementation to use when comparing elements of the collection.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(ICollection expected, ICollection actual, IComparer comparer)
|
||||
{
|
||||
AreEqual(expected, actual, comparer, String.Empty, null);
|
||||
AreEqual(expected, actual, comparer, string.Empty, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1078,7 +1078,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// test results.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(ICollection expected, ICollection actual, IComparer comparer, string message)
|
||||
|
@ -1111,7 +1111,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// An array of parameters to use when formatting <paramref name="message"/>.
|
||||
/// </param>
|
||||
/// <exception cref="AssertFailedException">
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// Thrown if <paramref name="expected"/> is not equal to
|
||||
/// <paramref name="actual"/>.
|
||||
/// </exception>
|
||||
public static void AreEqual(ICollection expected, ICollection actual, IComparer comparer, string message, params object[] parameters)
|
||||
|
@ -1218,7 +1218,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the first collection is a subset of the second
|
||||
/// collection. If either set contains duplicate elements, the number
|
||||
|
@ -1245,9 +1245,9 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
|
||||
// Count the occurrences of each object in both collections.
|
||||
int subsetNulls;
|
||||
Dictionary<Object, int> subsetElements = GetElementCounts(subset, out subsetNulls);
|
||||
Dictionary<object, int> subsetElements = GetElementCounts(subset, out subsetNulls);
|
||||
int supersetNulls;
|
||||
Dictionary<Object, int> supersetElements = GetElementCounts(superset, out supersetNulls);
|
||||
Dictionary<object, int> supersetElements = GetElementCounts(superset, out supersetNulls);
|
||||
|
||||
if (subsetNulls > supersetNulls)
|
||||
{
|
||||
|
@ -1272,7 +1272,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
// All the elements counts were OK.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a dictionary containing the number of occurrences of each
|
||||
/// element in the specified collection.
|
||||
|
@ -1291,7 +1291,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
{
|
||||
Debug.Assert(collection != null, "Collection is Null.");
|
||||
|
||||
Dictionary<Object, int> elementCounts = new Dictionary<Object, int>();
|
||||
Dictionary<object, int> elementCounts = new Dictionary<object, int>();
|
||||
nullCount = 0;
|
||||
|
||||
foreach (object element in collection)
|
||||
|
@ -1353,9 +1353,9 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
|
||||
// Count the occurrences of each object in the both collections
|
||||
int expectedNulls;
|
||||
Dictionary<Object, int> expectedElements = GetElementCounts(expected, out expectedNulls);
|
||||
Dictionary<object, int> expectedElements = GetElementCounts(expected, out expectedNulls);
|
||||
int actualNulls;
|
||||
Dictionary<Object, int> actualElements = GetElementCounts(actual, out actualNulls);
|
||||
Dictionary<object, int> actualElements = GetElementCounts(actual, out actualNulls);
|
||||
|
||||
if (actualNulls != expectedNulls)
|
||||
{
|
||||
|
@ -1392,7 +1392,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
Assert.CheckParameterNotNull(comparer, "Assert.AreCollectionsEqual", "comparer", string.Empty);
|
||||
if (!ReferenceEquals(expected, actual))
|
||||
{
|
||||
if ((null == expected) || (null == actual))
|
||||
if ((expected == null) || (actual == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1408,12 +1408,12 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
int i = 0;
|
||||
while (expectedEnum.MoveNext() && actualEnum.MoveNext())
|
||||
{
|
||||
bool areEqual = 0 == comparer.Compare(expectedEnum.Current, actualEnum.Current);
|
||||
bool areEqual = comparer.Compare(expectedEnum.Current, actualEnum.Current) == 0;
|
||||
if (!areEqual)
|
||||
{
|
||||
reason = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.ElementsAtIndexDontMatch,
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.ElementsAtIndexDontMatch,
|
||||
i);
|
||||
return false;
|
||||
}
|
|
@ -86,7 +86,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
{
|
||||
Assert.CheckParameterNotNull(value, "StringAssert.Contains", "value", string.Empty);
|
||||
Assert.CheckParameterNotNull(substring, "StringAssert.Contains", "substring", string.Empty);
|
||||
if (0 > value.IndexOf(substring, StringComparison.Ordinal))
|
||||
if (value.IndexOf(substring, StringComparison.Ordinal) < 0)
|
||||
{
|
||||
string finalMessage = string.Format(CultureInfo.CurrentCulture, FrameworkMessages.ContainsFail, value, substring, message);
|
||||
Assert.HandleFail("StringAssert.Contains", finalMessage, parameters);
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute to define inline data for a test method.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public class DataRowAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataRowAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="data1"> The data object. </param>
|
||||
public DataRowAttribute(object data1)
|
||||
{
|
||||
// Need to have this constructor explicitly to fix a CLS compliance error.
|
||||
this.Data = new object[] { data1 };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataRowAttribute"/> class which takes in an array of arguments.
|
||||
/// </summary>
|
||||
/// <param name="data1"> A data object. </param>
|
||||
/// <param name="moreData"> More data. </param>
|
||||
public DataRowAttribute(object data1, params object[] moreData)
|
||||
{
|
||||
this.Data = new object[moreData.Length + 1];
|
||||
this.Data[0] = data1;
|
||||
Array.Copy(moreData, 0, this.Data, 1, moreData.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets data for calling test method.
|
||||
/// </summary>
|
||||
public object[] Data { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets display name in test results for customization.
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for data driven test where data can be specified inline.
|
||||
/// </summary>
|
||||
|
@ -63,43 +63,4 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
return results.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute to define inline data for a test method.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public class DataRowAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// The constructor.
|
||||
/// </summary>
|
||||
/// <param name="data1"> The data object. </param>
|
||||
public DataRowAttribute(object data1)
|
||||
{
|
||||
// Need to have this constructor explicitly to fix a CLS compliance error.
|
||||
this.Data = new object[] { data1 };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor which takes in an array of arguments.
|
||||
/// </summary>
|
||||
/// <param name="data1"> A data object. </param>
|
||||
/// <param name="moreData"> More data. </param>
|
||||
public DataRowAttribute(object data1, params object[] moreData)
|
||||
{
|
||||
this.Data = new object[moreData.Length + 1];
|
||||
this.Data[0] = data1;
|
||||
Array.Copy(moreData, 0, this.Data, 1, moreData.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets data for calling test method.
|
||||
/// </summary>
|
||||
public object[] Data { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets display name in test results for customization.
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
}
|
||||
}
|
|
@ -5,10 +5,8 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute that specifies to expect an exception of the specified type
|
||||
|
@ -19,7 +17,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the expected type
|
||||
/// Initializes a new instance of the <see cref="ExpectedExceptionAttribute"/> class with the expected type
|
||||
/// </summary>
|
||||
/// <param name="exceptionType">Type of the expected exception</param>
|
||||
public ExpectedExceptionAttribute(Type exceptionType)
|
||||
|
@ -28,8 +26,8 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the expected type and the message to include when no exception is thrown by
|
||||
/// the test
|
||||
/// Initializes a new instance of the <see cref="ExpectedExceptionAttribute"/> class with
|
||||
/// the expected type and the message to include when no exception is thrown by the test.
|
||||
/// </summary>
|
||||
/// <param name="exceptionType">Type of the expected exception</param>
|
||||
/// <param name="noExceptionMessage">
|
||||
|
@ -55,6 +53,44 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating the Type of the expected exception
|
||||
/// </summary>
|
||||
public Type ExceptionType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to allow types derived from the type of the expected exception to
|
||||
/// qualify as expected
|
||||
/// </summary>
|
||||
public bool AllowDerivedTypes
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the message to include in the test result if the test fails due to not throwing an exception
|
||||
/// </summary>
|
||||
protected internal override string NoExceptionMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.UTF_TestMethodNoException,
|
||||
this.ExceptionType.FullName,
|
||||
this.SpecifiedNoExceptionMessage);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
|
@ -103,95 +139,5 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the message to include in the test result if the test fails due to not throwing an exception
|
||||
/// </summary>
|
||||
protected internal override string NoExceptionMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.UTF_TestMethodNoException,
|
||||
this.ExceptionType.FullName,
|
||||
this.SpecifiedNoExceptionMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating the Type of the expected exception
|
||||
/// </summary>
|
||||
public Type ExceptionType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to allow types derived from the type of the expected exception to
|
||||
/// qualify as expected
|
||||
/// </summary>
|
||||
public bool AllowDerivedTypes
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides helper functionality for the unit test framework
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
|
||||
Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
|
||||
internal static class UtfHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the exception messages, including the messages for all inner exceptions
|
||||
/// recursively
|
||||
/// </summary>
|
||||
/// <param name="ex">Exception to get messages for</param>
|
||||
/// <returns>string with error message information</returns>
|
||||
internal static string GetExceptionMsg(Exception ex)
|
||||
{
|
||||
Debug.Assert(ex != null, "exception is null");
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
bool first = true;
|
||||
for (Exception curException = ex;
|
||||
curException != null;
|
||||
curException = curException.InnerException)
|
||||
{
|
||||
// Get the exception message. Need to check for errors because the Message property
|
||||
// may have been overridden by the exception type in user code.
|
||||
string msg;
|
||||
try
|
||||
{
|
||||
msg = curException.Message;
|
||||
}
|
||||
catch
|
||||
{
|
||||
msg = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.UTF_FailedToGetExceptionMessage,
|
||||
curException.GetType());
|
||||
}
|
||||
|
||||
result.Append(
|
||||
string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
"{0}{1}: {2}",
|
||||
first ? String.Empty : " ---> ",
|
||||
curException.GetType(),
|
||||
msg));
|
||||
first = false;
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes with a default no-exception message
|
||||
/// Initializes a new instance of the <see cref="ExpectedExceptionBaseAttribute"/> class with a default no-exception message
|
||||
/// </summary>
|
||||
protected ExpectedExceptionBaseAttribute()
|
||||
: this(string.Empty)
|
||||
|
@ -25,7 +25,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the no-exception message
|
||||
/// Initializes a new instance of the <see cref="ExpectedExceptionBaseAttribute"/> class with a no-exception message
|
||||
/// </summary>
|
||||
/// <param name="noExceptionMessage">
|
||||
/// Message to include in the test result if the test fails due to not throwing an
|
||||
|
@ -45,12 +45,6 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
|
||||
// Todo: Test Context needs to be put in here for source compat.
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the message to include in the test result if the test fails due to not throwing an exception
|
||||
/// </summary>
|
||||
protected string SpecifiedNoExceptionMessage { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the message to include in the test result if the test fails due to not throwing an exception
|
||||
/// </summary>
|
||||
|
@ -70,21 +64,15 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the message to include in the test result if the test fails due to not throwing an exception
|
||||
/// </summary>
|
||||
protected string SpecifiedNoExceptionMessage { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the exception is expected. If the method returns, then it is
|
||||
/// understood that the exception was expected. If the method throws an exception, then it
|
||||
/// is understood that the exception was not expected, and the thrown exception's message
|
||||
/// is included in the test result. The <see cref="Assert"/> class can be used for
|
||||
/// convenience. If <see cref="Assert.Inconclusive()"/> is used and the assertion fails,
|
||||
/// then the test outcome is set to Inconclusive.
|
||||
/// </summary>
|
||||
/// <param name="exception">The exception thrown by the unit test</param>
|
||||
protected internal abstract void Verify(Exception exception);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default no-exception message
|
||||
/// </summary>
|
||||
|
@ -98,6 +86,17 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
expectedExceptionAttributeTypeName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the exception is expected. If the method returns, then it is
|
||||
/// understood that the exception was expected. If the method throws an exception, then it
|
||||
/// is understood that the exception was not expected, and the thrown exception's message
|
||||
/// is included in the test result. The <see cref="Assert"/> class can be used for
|
||||
/// convenience. If <see cref="Assert.Inconclusive()"/> is used and the assertion fails,
|
||||
/// then the test outcome is set to Inconclusive.
|
||||
/// </summary>
|
||||
/// <param name="exception">The exception thrown by the unit test</param>
|
||||
protected internal abstract void Verify(Exception exception);
|
||||
|
||||
/// <summary>
|
||||
/// Rethrow the exception if it is an AssertFailedException or an AssertInconclusiveException
|
||||
/// </summary>
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
/// <summary>
|
||||
/// TestCategory attribute; used to specify the category of a unit test.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
|
||||
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "The TestCategories accessor propety exposes the testCategory argument.")]
|
||||
public sealed class TestCategoryAttribute : TestCategoryBaseAttribute
|
||||
{
|
||||
private IList<string> testCategories;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestCategoryAttribute"/> class and applies the category to the test.
|
||||
/// </summary>
|
||||
/// <param name="testCategory">
|
||||
/// The test Category.
|
||||
/// </param>
|
||||
public TestCategoryAttribute(string testCategory)
|
||||
{
|
||||
List<string> categories = new List<string>(1);
|
||||
categories.Add(testCategory);
|
||||
this.testCategories = categories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the test categories that has been applied to the test.
|
||||
/// </summary>
|
||||
public override IList<string> TestCategories
|
||||
{
|
||||
get { return this.testCategories; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for the "Category" attribute
|
||||
|
@ -13,7 +12,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <remarks>
|
||||
/// The reason for this attribute is to let the users create their own implementation of test categories.
|
||||
/// - test framework (discovery, etc) deals with TestCategoryBaseAttribute.
|
||||
/// - The reason that TestCategories property is a collection rather than a string,
|
||||
/// - The reason that TestCategories property is a collection rather than a string,
|
||||
/// is to give more flexibility to the user. For instance the implementation may be based on enums for which the values can be OR'ed
|
||||
/// in which case it makes sense to have single attribute rather than multiple ones on the same test.
|
||||
/// </remarks>
|
||||
|
@ -21,6 +20,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public abstract class TestCategoryBaseAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestCategoryBaseAttribute"/> class.
|
||||
/// Applies the category to the test. The strings returned by TestCategories
|
||||
/// are used with the /category command to filter tests
|
||||
/// </summary>
|
||||
|
@ -29,42 +29,11 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The test category that has been applied to the test.
|
||||
/// Gets the test category that has been applied to the test.
|
||||
/// </summary>
|
||||
public abstract IList<string> TestCategories
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TestCategory attribute; used to specify the category of a unit test.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
|
||||
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "The TestCategories accessor propety exposes the testCategory argument.")]
|
||||
public sealed class TestCategoryAttribute : TestCategoryBaseAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Applies the category to the test.
|
||||
/// </summary>
|
||||
/// <param name="testCategory">
|
||||
/// The test Category.
|
||||
/// </param>
|
||||
public TestCategoryAttribute(string testCategory)
|
||||
{
|
||||
List<string> categories = new List<string>(1);
|
||||
categories.Add(testCategory);
|
||||
this.testCategories = categories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The test categories that has been applied to the test.
|
||||
/// </summary>
|
||||
public override IList<String> TestCategories
|
||||
{
|
||||
get { return this.testCategories; }
|
||||
}
|
||||
|
||||
private IList<string> testCategories;
|
||||
}
|
||||
}
|
|
@ -7,13 +7,15 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
|
||||
#pragma warning disable SA1402 // FileMayOnlyContainASingleType
|
||||
#pragma warning disable SA1649 // SA1649FileNameMustMatchTypeName
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for timeouts, that can be used with the <see cref="TimeoutAttribute"/> class.
|
||||
/// The type of the enumeration must match
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Justification ="Compat reasons")]
|
||||
public enum TestTimeout
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -22,75 +24,6 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
Infinite = int.MaxValue
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TestMethod for execution.
|
||||
/// </summary>
|
||||
public interface ITestMethod
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of test method.
|
||||
/// </summary>
|
||||
string TestMethodName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of test class.
|
||||
/// </summary>
|
||||
string TestClassName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the return type of test method.
|
||||
/// </summary>
|
||||
Type ReturnType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameters of test method.
|
||||
/// </summary>
|
||||
ParameterInfo[] ParameterTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the methodInfo for test method. Should not be used to invoke test method.
|
||||
/// Its just for any other info may needed by extension.
|
||||
/// </summary>
|
||||
MethodInfo MethodInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the test method.
|
||||
/// </summary>
|
||||
/// <param name="arguments">
|
||||
/// Arguments to pass to test method. (E.g. For data driven)
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Result of test method invocation.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// This call handles asynchronous test methods as well.
|
||||
/// </remarks>
|
||||
TestResult Invoke(object[] arguments);
|
||||
|
||||
/// <summary>
|
||||
/// Get all attributes of the test method.
|
||||
/// </summary>
|
||||
/// <param name="inherit">
|
||||
/// Whether attribute defined in parent class is valid.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// All attributes.
|
||||
/// </returns>
|
||||
Attribute[] GetAllAttributes(bool inherit);
|
||||
|
||||
/// <summary>
|
||||
/// Get attribute of specific type.
|
||||
/// </summary>
|
||||
/// <typeparam name="AttributeType"> System.Attribute type. </typeparam>
|
||||
/// <param name="inherit">
|
||||
/// Whether attribute defined in parent class is valid.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The attributes of the specified type.
|
||||
/// </returns>
|
||||
AttributeType[] GetAttributes<AttributeType>(bool inherit) where AttributeType : Attribute;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The test class attribute.
|
||||
/// </summary>
|
||||
|
@ -281,7 +214,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public sealed class DescriptionAttribute : TestPropertyAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor to describe a test.
|
||||
/// Initializes a new instance of the <see cref="DescriptionAttribute"/> class to describe a test.
|
||||
/// </summary>
|
||||
/// <param name="description">The description.</param>
|
||||
public DescriptionAttribute(string description)
|
||||
|
@ -303,7 +236,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public sealed class CssProjectStructureAttribute : TestPropertyAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for CSS Project Structure URI.
|
||||
/// Initializes a new instance of the <see cref="CssProjectStructureAttribute"/> class for CSS Project Structure URI.
|
||||
/// </summary>
|
||||
/// <param name="cssProjectStructure">The CSS Project Structure URI.</param>
|
||||
public CssProjectStructureAttribute(string cssProjectStructure)
|
||||
|
@ -318,7 +251,6 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public string CssProjectStructure { get; private set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// CSS Iteration URI
|
||||
/// </summary>
|
||||
|
@ -326,7 +258,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public sealed class CssIterationAttribute : TestPropertyAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for CSS Iteration URI.
|
||||
/// Initializes a new instance of the <see cref="CssIterationAttribute"/> class for CSS Iteration URI.
|
||||
/// </summary>
|
||||
/// <param name="cssIteration">The CSS Iteration URI.</param>
|
||||
public CssIterationAttribute(string cssIteration)
|
||||
|
@ -348,7 +280,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public sealed class WorkItemAttribute : TestPropertyAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for the WorkItem Attribute.
|
||||
/// Initializes a new instance of the <see cref="WorkItemAttribute"/> class for the WorkItem Attribute.
|
||||
/// </summary>
|
||||
/// <param name="id">The Id to a work item.</param>
|
||||
public WorkItemAttribute(int id)
|
||||
|
@ -385,7 +317,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the instance with a preset timeout
|
||||
/// Initializes a new instance of the <see cref="TimeoutAttribute"/> class with a preset timeout
|
||||
/// </summary>
|
||||
/// <param name="timeout">
|
||||
/// The timeout
|
||||
|
@ -412,7 +344,6 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// </summary>
|
||||
public class TestResult
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestResult"/> class.
|
||||
/// </summary>
|
||||
|
@ -458,7 +389,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public TimeSpan Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data row index in data source. Set only for results of individual
|
||||
/// Gets or sets the data row index in data source. Set only for results of individual
|
||||
/// run of data row of a data driven test.
|
||||
/// </summary>
|
||||
public int DatarowIndex { get; set; }
|
||||
|
@ -469,7 +400,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public object ReturnValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Result files attached by the test.
|
||||
/// Gets or sets the result files attached by the test.
|
||||
/// </summary>
|
||||
public IList<string> ResultFiles { get; set; }
|
||||
}
|
||||
|
@ -489,7 +420,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
public sealed class DeploymentItemAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="DeploymentItemAttribute"/> class
|
||||
/// Initializes a new instance of the <see cref="DeploymentItemAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="path">The file or directory to deploy. The path is relative to the build output directory. The item will be copied to the same directory as the deployed test assemblies.</param>
|
||||
public DeploymentItemAttribute(string path)
|
||||
|
@ -499,7 +430,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="DeploymentItemAttribute"/> class
|
||||
/// Initializes a new instance of the <see cref="DeploymentItemAttribute"/> class
|
||||
/// </summary>
|
||||
/// <param name="path">The relative or absolute path to the file or directory to deploy. The path is relative to the build output directory. The item will be copied to the same directory as the deployed test assemblies.</param>
|
||||
/// <param name="outputDirectory">The path of the directory to which the items are to be copied. It can be either absolute or relative to the deployment directory. All files and directories identified by <paramref name="path"/> will be copied to this directory.</param>
|
||||
|
@ -527,17 +458,19 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// [DataSource("Provider=SQLOLEDB.1;Data Source=source;Integrated Security=SSPI;Initial Catalog=EqtCoverage;Persist Security Info=False", "MyTable")]
|
||||
/// [DataSource("dataSourceNameFromConfigFile")]
|
||||
/// </example>
|
||||
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification ="Compat")]
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public sealed class DataSourceAttribute : Attribute
|
||||
{
|
||||
// DefaultProviderName needs not to be constant so that clients do not need
|
||||
// to recompile if the value changes.
|
||||
|
||||
/// <summary>
|
||||
/// The default provider name for DataSource.
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Performance", "CA1802:UseLiteralsWhereAppropriate")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1802:UseLiteralsWhereAppropriate", Justification ="Compat")]
|
||||
public static readonly string DefaultProviderName = "System.Data.OleDb";
|
||||
|
||||
/// <summary>
|
||||
/// The default data access method.
|
||||
/// </summary>
|
||||
|
@ -548,9 +481,9 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// </summary>
|
||||
/// <param name="providerInvariantName">Invariant data provider name, such as System.Data.SqlClient</param>
|
||||
/// <param name="connectionString">
|
||||
/// Data provider specific connection string.
|
||||
/// Data provider specific connection string.
|
||||
/// WARNING: The connection string can contain sensitive data (for example, a password).
|
||||
/// The connection string is stored in plain text in source code and in the compiled assembly.
|
||||
/// The connection string is stored in plain text in source code and in the compiled assembly.
|
||||
/// Restrict access to the source code and assembly to protect this sensitive information.
|
||||
/// </param>
|
||||
/// <param name="tableName">The name of the data table.</param>
|
||||
|
@ -568,9 +501,9 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// Specify connection string and data table to access OLEDB data source.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">
|
||||
/// Data provider specific connection string.
|
||||
/// Data provider specific connection string.
|
||||
/// WARNING: The connection string can contain sensitive data (for example, a password).
|
||||
/// The connection string is stored in plain text in source code and in the compiled assembly.
|
||||
/// The connection string is stored in plain text in source code and in the compiled assembly.
|
||||
/// Restrict access to the source code and assembly to protect this sensitive information.
|
||||
/// </param>
|
||||
/// <param name="tableName">The name of the data table.</param>
|
||||
|
@ -588,12 +521,11 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
this.DataSourceSettingName = dataSourceSettingName;
|
||||
}
|
||||
|
||||
|
||||
// Different providers use dfferent connection strings and provider itself is a part of connection string.
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value representing the data provider of the data source.
|
||||
/// </summary>
|
||||
///
|
||||
/// <returns>
|
||||
/// The data provider name. If a data provider was not designated at object initialization, the default provider of System.Data.OleDb will be returned.
|
||||
/// </returns>
|
||||
|
@ -612,15 +544,18 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <summary>
|
||||
/// Gets the method used to access the data source.
|
||||
/// </summary>
|
||||
///
|
||||
///
|
||||
/// <returns>
|
||||
/// One of the <see cref="T:Microsoft.VisualStudio.TestTools.UnitTesting.DataAccessMethod"/> values. If the <see cref="DataSourceAttribute"/> is not initialized, this will return the default value <see cref="F:Microsoft.VisualStudio.TestTools.UnitTesting.DataAccessMethod.Random"/>.
|
||||
/// </returns>
|
||||
public DataAccessMethod DataAccessMethod { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of a data source found in the <microsoft.visualstudio.qualitytools> section in the app.config file.
|
||||
/// Gets the name of a data source found in the <microsoft.visualstudio.qualitytools> section in the app.config file.
|
||||
/// </summary>
|
||||
public string DataSourceSettingName { get; }
|
||||
}
|
||||
|
||||
#pragma warning restore SA1402 // FileMayOnlyContainASingleType
|
||||
#pragma warning restore SA1649 // SA1649FileNameMustMatchTypeName
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// AssertFailedException class. Used to indicate failure for a test case
|
||||
/// </summary>
|
||||
public partial class AssertFailedException : UnitTestAssertException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertFailedException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
/// <param name="ex"> The exception. </param>
|
||||
public AssertFailedException(string msg, Exception ex)
|
||||
: base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertFailedException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
public AssertFailedException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertFailedException"/> class.
|
||||
/// </summary>
|
||||
public AssertFailedException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// The assert inconclusive exception.
|
||||
/// </summary>
|
||||
public partial class AssertInconclusiveException : UnitTestAssertException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertInconclusiveException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
/// <param name="ex"> The exception. </param>
|
||||
public AssertInconclusiveException(string msg, Exception ex)
|
||||
: base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertInconclusiveException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
public AssertInconclusiveException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssertInconclusiveException"/> class.
|
||||
/// </summary>
|
||||
public AssertInconclusiveException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// InternalTestFailureException class. Used to indicate internal failure for a test case
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is only added to preserve source compatibility with the V1 framework.
|
||||
/// For all practical purposes either use AssertFailedException/AssertInconclusiveException.
|
||||
/// </remarks>
|
||||
public class InternalTestFailureException : UnitTestAssertException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InternalTestFailureException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The exception message. </param>
|
||||
/// <param name="ex"> The exception. </param>
|
||||
public InternalTestFailureException(string msg, Exception ex)
|
||||
: base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InternalTestFailureException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The exception message. </param>
|
||||
public InternalTestFailureException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InternalTestFailureException"/> class.
|
||||
/// </summary>
|
||||
public InternalTestFailureException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for Framework Exceptions.
|
||||
/// </summary>
|
||||
public abstract partial class UnitTestAssertException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UnitTestAssertException"/> class.
|
||||
/// </summary>
|
||||
protected UnitTestAssertException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UnitTestAssertException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
/// <param name="ex"> The exception. </param>
|
||||
protected UnitTestAssertException(string msg, Exception ex)
|
||||
: base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UnitTestAssertException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg"> The message. </param>
|
||||
protected UnitTestAssertException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,8 +15,10 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// 1. public default constructor
|
||||
/// 2. implements common interface: IComparable, IEnumerable
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1036:OverrideMethodsOnComparableTypes")] // This next suppression could mask a problem, since Equals and CompareTo may not agree!
|
||||
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "Compat reasons.")]
|
||||
|
||||
// This next suppression could mask a problem, since Equals and CompareTo may not agree!
|
||||
[SuppressMessage("Microsoft.Design", "CA1036:OverrideMethodsOnComparableTypes", Justification = "Compat reasons.")]
|
||||
|
||||
// GenericParameterHelper in full CLR version also implements ICloneable, but we dont have ICloneable in core CLR
|
||||
public class GenericParameterHelper : IComparable, IEnumerable
|
||||
|
@ -28,10 +30,14 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Public default constructor, satisfies the 'newable' constraint in C# generics.
|
||||
/// This constructor initializes the Data property to a random value.
|
||||
/// Initializes a new instance of the <see cref="GenericParameterHelper"/> class that
|
||||
/// satisfies the 'newable' constraint in C# generics.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This constructor initializes the Data property to a random value.
|
||||
/// </remarks>
|
||||
public GenericParameterHelper()
|
||||
{
|
||||
Random randomizer = new Random();
|
||||
|
@ -39,7 +45,8 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// This constructor initializes the Data property to a user-supplied value
|
||||
/// Initializes a new instance of the <see cref="GenericParameterHelper"/> class that
|
||||
/// initializes the Data property to a user-supplied value.
|
||||
/// </summary>
|
||||
/// <param name="data">Any integer value</param>
|
||||
public GenericParameterHelper(int data)
|
||||
|
@ -49,6 +56,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Data
|
||||
/// </summary>
|
||||
|
@ -60,6 +68,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
#endregion
|
||||
|
||||
#region Object Overrides
|
||||
|
||||
/// <summary>
|
||||
/// Do the value comparison for two GenericParameterHelper object
|
||||
/// </summary>
|
||||
|
@ -76,7 +85,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
/// <summary>
|
||||
/// Returns a hashcode for this object.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>The hash code.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.Data.GetHashCode();
|
||||
|
@ -102,40 +111,44 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
{
|
||||
return this.Data.CompareTo(gpf.Data);
|
||||
}
|
||||
|
||||
throw new NotSupportedException("GenericParameterHelper object is designed to compare objects of GenericParameterHelper type only.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
|
||||
/// <summary>
|
||||
/// Returns an IEnumerator object whose length is derived from
|
||||
/// the Data property.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>The IEnumerator object</returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
int size = this.Data % 10;
|
||||
if (this.ienumerableStore == null)
|
||||
{
|
||||
this.ienumerableStore = new List<Object>(size);
|
||||
this.ienumerableStore = new List<object>(size);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
this.ienumerableStore.Add(new Object());
|
||||
this.ienumerableStore.Add(new object());
|
||||
}
|
||||
}
|
||||
|
||||
return this.ienumerableStore.GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
|
||||
/// <summary>
|
||||
/// Returns a GenericParameterHelper object that is equal to
|
||||
/// Returns a GenericParameterHelper object that is equal to
|
||||
/// 'this' one.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>The cloned object.</returns>
|
||||
public object Clone()
|
||||
{
|
||||
GenericParameterHelper clone = new GenericParameterHelper { data = this.data };
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
/// <summary>
|
||||
/// TestMethod for execution.
|
||||
/// </summary>
|
||||
public interface ITestMethod
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of test method.
|
||||
/// </summary>
|
||||
string TestMethodName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of test class.
|
||||
/// </summary>
|
||||
string TestClassName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the return type of test method.
|
||||
/// </summary>
|
||||
Type ReturnType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameters of test method.
|
||||
/// </summary>
|
||||
ParameterInfo[] ParameterTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the methodInfo for test method. Should not be used to invoke test method.
|
||||
/// Its just for any other info may needed by extension.
|
||||
/// </summary>
|
||||
MethodInfo MethodInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the test method.
|
||||
/// </summary>
|
||||
/// <param name="arguments">
|
||||
/// Arguments to pass to test method. (E.g. For data driven)
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Result of test method invocation.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// This call handles asynchronous test methods as well.
|
||||
/// </remarks>
|
||||
TestResult Invoke(object[] arguments);
|
||||
|
||||
/// <summary>
|
||||
/// Get all attributes of the test method.
|
||||
/// </summary>
|
||||
/// <param name="inherit">
|
||||
/// Whether attribute defined in parent class is valid.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// All attributes.
|
||||
/// </returns>
|
||||
Attribute[] GetAllAttributes(bool inherit);
|
||||
|
||||
/// <summary>
|
||||
/// Get attribute of specific type.
|
||||
/// </summary>
|
||||
/// <typeparam name="AttributeType"> System.Attribute type. </typeparam>
|
||||
/// <param name="inherit">
|
||||
/// Whether attribute defined in parent class is valid.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The attributes of the specified type.
|
||||
/// </returns>
|
||||
AttributeType[] GetAttributes<AttributeType>(bool inherit)
|
||||
where AttributeType : Attribute;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
/// The helper.
|
||||
/// </summary>
|
||||
internal static class Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// The check parameter not null.
|
||||
/// </summary>
|
||||
/// <param name="param">
|
||||
/// The parameter.
|
||||
/// </param>
|
||||
/// <param name="parameterName">
|
||||
/// The parameter name.
|
||||
/// </param>
|
||||
/// <param name="message">
|
||||
/// The message.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException"> Throws argument null exception when parameter is null. </exception>
|
||||
internal static void CheckParameterNotNull(object param, string parameterName, string message)
|
||||
{
|
||||
if (param == null)
|
||||
{
|
||||
throw new ArgumentNullException(parameterName, message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The check parameter not null or empty.
|
||||
/// </summary>
|
||||
/// <param name="param">
|
||||
/// The parameter.
|
||||
/// </param>
|
||||
/// <param name="parameterName">
|
||||
/// The parameter name.
|
||||
/// </param>
|
||||
/// <param name="message">
|
||||
/// The message.
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentException"> Throws ArgumentException when parameter is null. </exception>
|
||||
internal static void CheckParameterNotNullOrEmpty(string param, string parameterName, string message)
|
||||
{
|
||||
if (string.IsNullOrEmpty(param))
|
||||
{
|
||||
throw new ArgumentException(parameterName, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Provides helper functionality for the unit test framework
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
|
||||
internal static class UtfHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the exception messages, including the messages for all inner exceptions
|
||||
/// recursively
|
||||
/// </summary>
|
||||
/// <param name="ex">Exception to get messages for</param>
|
||||
/// <returns>string with error message information</returns>
|
||||
internal static string GetExceptionMsg(Exception ex)
|
||||
{
|
||||
Debug.Assert(ex != null, "exception is null");
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
bool first = true;
|
||||
for (Exception curException = ex;
|
||||
curException != null;
|
||||
curException = curException.InnerException)
|
||||
{
|
||||
// Get the exception message. Need to check for errors because the Message property
|
||||
// may have been overridden by the exception type in user code.
|
||||
string msg;
|
||||
try
|
||||
{
|
||||
msg = curException.Message;
|
||||
}
|
||||
catch
|
||||
{
|
||||
msg = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
FrameworkMessages.UTF_FailedToGetExceptionMessage,
|
||||
curException.GetType());
|
||||
}
|
||||
|
||||
result.Append(
|
||||
string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
"{0}{1}: {2}",
|
||||
first ? string.Empty : " ---> ",
|
||||
curException.GetType(),
|
||||
msg));
|
||||
first = false;
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,10 +30,9 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting.Logging
|
|||
/// </summary>
|
||||
/// <param name="format">String format with placeholders.</param>
|
||||
/// <param name="args">Parameters for placeholders.</param>
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
|
||||
Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")]
|
||||
public static void LogMessage(string format, params object[] args)
|
||||
{
|
||||
{
|
||||
if (OnLogMessage != null)
|
||||
{
|
||||
if (format == null)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<AssemblyLclSubPath>\</AssemblyLclSubPath>
|
||||
<ShouldEnableStyleCop>true</ShouldEnableStyleCop>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -42,29 +43,42 @@
|
|||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Interfaces\ITestMethod.cs" />
|
||||
<Compile Include="Internal\Helper.cs" />
|
||||
<Compile Include="DataAccessMethod.cs" />
|
||||
<Compile Include="ExpectedExceptionAttribute.cs" />
|
||||
<Compile Include="ExpectedExceptionBaseAttribute.cs" />
|
||||
<Compile Include="Attributes\DataRowAttribute.cs" />
|
||||
<Compile Include="Exceptions\AssertInconclusiveException.cs" />
|
||||
<Compile Include="Exceptions\InternalTestFailureException.cs" />
|
||||
<Compile Include="Attributes\ExpectedExceptionAttribute.cs" />
|
||||
<Compile Include="Attributes\ExpectedExceptionBaseAttribute.cs" />
|
||||
<Compile Include="Friends.cs" />
|
||||
<Compile Include="GenericParameterHelper.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="CategoryAttribute.cs" />
|
||||
<Compile Include="AssertFailedException.cs" />
|
||||
<Compile Include="Assertion.cs" />
|
||||
<Compile Include="StringAssertion.cs" />
|
||||
<Compile Include="CollectionsAssertion.cs" />
|
||||
<Compile Include="Attributes\TestCategoryAttribute.cs" />
|
||||
<Compile Include="Attributes\TestCategoryBaseAttribute.cs" />
|
||||
<Compile Include="Exceptions\AssertFailedException.cs" />
|
||||
<Compile Include="Assertions\Assert.cs" />
|
||||
<Compile Include="Assertions\StringAssert.cs" />
|
||||
<Compile Include="Assertions\CollectionAssert.cs" />
|
||||
<Compile Include="Exceptions\UnitTestAssertException.cs" />
|
||||
<Compile Include="UnitTestOutcome.cs" />
|
||||
<Compile Include="FrameworkMessages.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>FrameworkMessages.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="VSTestAttributes.cs" />
|
||||
<Compile Include="DataTestMethodAttribute.cs" />
|
||||
<Compile Include="Internal\UtfHelper.cs" />
|
||||
<Compile Include="Attributes\VSTestAttributes.cs" />
|
||||
<Compile Include="Attributes\DataTestMethodAttribute.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="$(TestFxRoot)scripts\build\stylecop.json">
|
||||
<Link>stylecop.json</Link>
|
||||
</AdditionalFiles>
|
||||
</ItemGroup>
|
||||
<Import Project="$(TestFxRoot)scripts\build\TestFx.targets" />
|
||||
</Project>
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MSTest.Core")]
|
||||
|
@ -20,12 +20,12 @@ using System.Reflection;
|
|||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
//[assembly: AssemblyVersion("1.0.0.0")]
|
||||
//[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
// [assembly: AssemblyVersion("1.0.0.0")]
|
||||
// [assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
|
|||
Timeout,
|
||||
|
||||
/// <summary>
|
||||
/// Test was aborted by the user.
|
||||
/// Test was aborted by the user.
|
||||
/// </summary>
|
||||
Aborted,
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MicroBuild.Core" version="0.2.0" targetFramework="portable45-net45+win8+wp8+wpa81" developmentDependency="true" />
|
||||
<package id="StyleCop.Analyzers" version="1.0.0" targetFramework="portable45-net45+win8+wp8+wpa81" developmentDependency="true" />
|
||||
</packages>
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace UnitTestFramework.Tests
|
||||
|
@ -8,18 +8,16 @@ namespace UnitTestFramework.Tests
|
|||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using MSTestAdapter.TestUtilities;
|
||||
|
||||
using Assert = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
|
||||
using StringAssert = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert;
|
||||
using TestClass = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
|
||||
using TestMethod = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
|
||||
|
||||
using TestFrameworkV2 = FrameworkV2.Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TestMethod = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
|
||||
|
||||
[TestClass]
|
||||
public class AssertionTests
|
||||
public class AssertTests
|
||||
{
|
||||
#region ThrowsException tests
|
||||
|
||||
|
@ -64,7 +62,7 @@ namespace UnitTestFramework.Tests
|
|||
// Should not throw an exception.
|
||||
await t;
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void ThrowsExceptionAsyncShouldThrowAssertionOnNoException()
|
||||
{
|
||||
|
@ -163,7 +161,7 @@ namespace UnitTestFramework.Tests
|
|||
{
|
||||
Task t = TestFrameworkV2.Assert.ThrowsExceptionAsync<ArgumentException>(async () => { await Task.FromResult(true); }, null, null);
|
||||
t.Wait();
|
||||
};
|
||||
};
|
||||
ActionUtility.ActionShouldThrowInnerExceptionOfType(a, typeof(ArgumentNullException));
|
||||
}
|
||||
|
||||
|
@ -175,7 +173,10 @@ namespace UnitTestFramework.Tests
|
|||
{
|
||||
await Task.Delay(5);
|
||||
},
|
||||
"The world is not on fire {0}.{1}-{2}.", "ta" , "da", 123);
|
||||
"The world is not on fire {0}.{1}-{2}.",
|
||||
"ta",
|
||||
"da",
|
||||
123);
|
||||
var ex = ActionUtility.PerformActionAndReturnException(() => t.Wait());
|
||||
|
||||
Assert.IsNotNull(ex);
|
||||
|
@ -196,7 +197,9 @@ namespace UnitTestFramework.Tests
|
|||
await Task.Delay(5);
|
||||
throw new FormatException();
|
||||
},
|
||||
"Happily ever after. {0} {1}.", "The", "End");
|
||||
"Happily ever after. {0} {1}.",
|
||||
"The",
|
||||
"End");
|
||||
var ex = ActionUtility.PerformActionAndReturnException(() => t.Wait());
|
||||
|
||||
Assert.IsNotNull(ex);
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace UnitTestFramework.Tests
|
||||
{
|
||||
extern alias FrameworkV1;
|
||||
extern alias FrameworkV2;
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -33,19 +33,21 @@ namespace UnitTestFramework.Tests
|
|||
{
|
||||
int dummyIntData = 2;
|
||||
string dummyStringData = "DummyString";
|
||||
TestFrameworkV2.DataRowAttribute dataRowAttribute = new TestFrameworkV2.DataRowAttribute(dummyIntData,
|
||||
TestFrameworkV2.DataRowAttribute dataRowAttribute = new TestFrameworkV2.DataRowAttribute(
|
||||
dummyIntData,
|
||||
dummyStringData);
|
||||
dataRowAttribute.DisplayName = "DataRowTestDisplayName";
|
||||
|
||||
TestFrameworkV2.TestResult testResult = new TestFrameworkV2.TestResult();
|
||||
|
||||
//Setup mocks.
|
||||
// Setup mocks.
|
||||
this.testMethod.Setup(tm => tm.TestMethodName).Returns("DummyTestMethod");
|
||||
this.testMethod.Setup(tm => tm.Invoke(It.IsAny<object[]>())).Returns(testResult);
|
||||
|
||||
//Act.
|
||||
// Act.
|
||||
TestFrameworkV2.TestResult[] results =
|
||||
TestFrameworkV2.DataTestMethodAttribute.RunDataDrivenTest(this.testMethod.Object,
|
||||
TestFrameworkV2.DataTestMethodAttribute.RunDataDrivenTest(
|
||||
this.testMethod.Object,
|
||||
new TestFrameworkV2.DataRowAttribute[] { dataRowAttribute });
|
||||
|
||||
TestFrameworkV2.Assert.AreEqual(results[0].DisplayName, "DataRowTestDisplayName");
|
||||
|
@ -56,18 +58,20 @@ namespace UnitTestFramework.Tests
|
|||
{
|
||||
int dummyIntData = 2;
|
||||
string dummyStringData = "DummyString";
|
||||
TestFrameworkV2.DataRowAttribute dataRowAttribute = new TestFrameworkV2.DataRowAttribute(dummyIntData,
|
||||
TestFrameworkV2.DataRowAttribute dataRowAttribute = new TestFrameworkV2.DataRowAttribute(
|
||||
dummyIntData,
|
||||
dummyStringData);
|
||||
|
||||
TestFrameworkV2.TestResult testResult = new TestFrameworkV2.TestResult();
|
||||
|
||||
//Setup mocks.
|
||||
// Setup mocks.
|
||||
this.testMethod.Setup(tm => tm.TestMethodName).Returns("DummyTestMethod");
|
||||
this.testMethod.Setup(tm => tm.Invoke(It.IsAny<object[]>())).Returns(testResult);
|
||||
|
||||
//Act.
|
||||
// Act.
|
||||
TestFrameworkV2.TestResult[] results =
|
||||
TestFrameworkV2.DataTestMethodAttribute.RunDataDrivenTest(this.testMethod.Object,
|
||||
TestFrameworkV2.DataTestMethodAttribute.RunDataDrivenTest(
|
||||
this.testMethod.Object,
|
||||
new TestFrameworkV2.DataRowAttribute[] { dataRowAttribute });
|
||||
|
||||
TestFrameworkV2.Assert.AreEqual(results[0].DisplayName, "DummyTestMethod (2,DummyString)");
|
||||
|
@ -82,14 +86,15 @@ namespace UnitTestFramework.Tests
|
|||
TestFrameworkV2.DataRowAttribute dataRowAttribute2 = new TestFrameworkV2.DataRowAttribute(dummyIntData2);
|
||||
|
||||
TestFrameworkV2.TestResult testResult = new TestFrameworkV2.TestResult();
|
||||
testResult.ResultFiles = new List<string>() {"C:\\temp.txt"};
|
||||
testResult.ResultFiles = new List<string>() { "C:\\temp.txt" };
|
||||
|
||||
//Setup mocks.
|
||||
// Setup mocks.
|
||||
this.testMethod.Setup(tm => tm.Invoke(It.IsAny<object[]>())).Returns(testResult);
|
||||
|
||||
//Act.
|
||||
// Act.
|
||||
TestFrameworkV2.TestResult[] results =
|
||||
TestFrameworkV2.DataTestMethodAttribute.RunDataDrivenTest(this.testMethod.Object,
|
||||
TestFrameworkV2.DataTestMethodAttribute.RunDataDrivenTest(
|
||||
this.testMethod.Object,
|
||||
new TestFrameworkV2.DataRowAttribute[] { dataRowAttribute1, dataRowAttribute2 });
|
||||
|
||||
TestFrameworkV1.CollectionAssert.Contains(results[0].ResultFiles.ToList(), "C:\\temp.txt");
|
|
@ -7,10 +7,10 @@ namespace UnitTestFramework.Tests
|
|||
extern alias FrameworkV2;
|
||||
|
||||
using System;
|
||||
using MSTestAdapter.TestUtilities;
|
||||
|
||||
using TestFrameworkV1 = FrameworkV1.Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TestFrameworkV2 = FrameworkV2.Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MSTestAdapter.TestUtilities;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for class ExpectedExceptionAttribute
|
||||
|
@ -62,7 +62,7 @@ namespace UnitTestFramework.Tests
|
|||
public void GetExceptionMsgShouldReturnInnerExceptionMessageAsWellIfPresent()
|
||||
{
|
||||
Exception innerException = new DivideByZeroException();
|
||||
Exception ex = new Exception("Dummy Exception",innerException);
|
||||
Exception ex = new Exception("Dummy Exception", innerException);
|
||||
var actualMessage = TestFrameworkV2.UtfHelper.GetExceptionMsg(ex);
|
||||
var expectedMessage = "System.Exception: Dummy Exception ---> System.DivideByZeroException: Attempted to divide by zero.";
|
||||
TestFrameworkV2.Assert.AreEqual(expectedMessage, actualMessage);
|
|
@ -7,10 +7,10 @@ namespace UnitTestFramework.Tests
|
|||
extern alias FrameworkV2;
|
||||
|
||||
using System;
|
||||
using MSTestAdapter.TestUtilities;
|
||||
|
||||
using TestFrameworkV1 = FrameworkV1.Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TestFrameworkV2 = FrameworkV2.Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MSTestAdapter.TestUtilities;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for class ExpectedExceptionBaseAttribute
|
||||
|
@ -69,7 +69,7 @@ namespace UnitTestFramework.Tests
|
|||
|
||||
string result = this.sut.GetNoExceptionMessage();
|
||||
|
||||
TestFrameworkV1.Assert.IsTrue(String.IsNullOrEmpty(result));
|
||||
TestFrameworkV1.Assert.IsTrue(string.IsNullOrEmpty(result));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,11 +78,13 @@ namespace UnitTestFramework.Tests
|
|||
/// </summary>
|
||||
public class TestableExpectedExceptionBaseAttributeClass : TestFrameworkV2.ExpectedExceptionBaseAttribute
|
||||
{
|
||||
public TestableExpectedExceptionBaseAttributeClass() : base()
|
||||
public TestableExpectedExceptionBaseAttributeClass()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public TestableExpectedExceptionBaseAttributeClass(string noExceptionMessage) : base(noExceptionMessage)
|
||||
public TestableExpectedExceptionBaseAttributeClass(string noExceptionMessage)
|
||||
: base(noExceptionMessage)
|
||||
{
|
||||
}
|
||||
|
|
@ -7,10 +7,10 @@ namespace UnitTestFramework.Tests
|
|||
extern alias FrameworkV2;
|
||||
|
||||
using System;
|
||||
using MSTestAdapter.TestUtilities;
|
||||
|
||||
using TestFrameworkV1 = FrameworkV1.Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TestFrameworkV2 = FrameworkV2.Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MSTestAdapter.TestUtilities;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for class GenericParameterHelper
|
||||
|
@ -68,7 +68,7 @@ namespace UnitTestFramework.Tests
|
|||
{
|
||||
this.sut = new TestFrameworkV2.GenericParameterHelper(15);
|
||||
|
||||
int expectedLenghtOfList = 5; //(15%10)
|
||||
int expectedLenghtOfList = 5; // (15%10)
|
||||
int result = 0;
|
||||
|
||||
foreach (var x in this.sut)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<ShouldEnableStyleCop>true</ShouldEnableStyleCop>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -63,16 +64,21 @@
|
|||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssertionTests.cs" />
|
||||
<Compile Include="DataTestMethodAttributeTests.cs" />
|
||||
<Compile Include="ExpectedExceptionAttributeTests.cs" />
|
||||
<Compile Include="ExpectedExceptionBaseAttributeTests.cs" />
|
||||
<Compile Include="Assertions\AssertTests.cs" />
|
||||
<Compile Include="Attributes\DataTestMethodAttributeTests.cs" />
|
||||
<Compile Include="Attributes\ExpectedExceptionAttributeTests.cs" />
|
||||
<Compile Include="Attributes\ExpectedExceptionBaseAttributeTests.cs" />
|
||||
<Compile Include="GenericParameterHelperTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="$(TestFxRoot)scripts\build\stylecop.json">
|
||||
<Link>stylecop.json</Link>
|
||||
</AdditionalFiles>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(TestFxRoot)scripts\build\TestFx.targets" />
|
||||
</Project>
|
|
@ -4,7 +4,7 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MSTest.Core.Unit.Tests")]
|
||||
|
@ -16,8 +16,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
|
@ -27,12 +27,12 @@ using System.Runtime.InteropServices;
|
|||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
//[assembly: AssemblyVersion("1.0.0.0")]
|
||||
//[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
// [assembly: AssemblyVersion("1.0.0.0")]
|
||||
// [assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
<packages>
|
||||
<package id="Castle.Core" version="3.3.3" targetFramework="net452" />
|
||||
<package id="Moq" version="4.5.21" targetFramework="net452" />
|
||||
<package id="StyleCop.Analyzers" version="1.0.0" targetFramework="net452" developmentDependency="true" />
|
||||
</packages>
|
Загрузка…
Ссылка в новой задаче