Skip to content

Commit 4d52f05

Browse files
committed
Rename Helper.cs into Guard.cs
1 parent 0ee0586 commit 4d52f05

File tree

3 files changed

+37
-53
lines changed

3 files changed

+37
-53
lines changed

src/TestFramework/TestFramework.Extensions/PrivateObject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public PrivateObject(string assemblyName, string typeName, Type[]? parameterType
9696
public PrivateObject(Type type, params object?[]? args)
9797
: this(type, null, args)
9898
{
99-
Helper.CheckParameterNotNull(type, "type", string.Empty);
99+
Guard.IsNotNull(type, "type", string.Empty);
100100
}
101101

102102
/// <summary>
@@ -108,7 +108,7 @@ public PrivateObject(Type type, params object?[]? args)
108108
/// <param name="args">Arguments to pass to the constructor.</param>
109109
public PrivateObject(Type type, Type[]? parameterTypes, object?[]? args)
110110
{
111-
Helper.CheckParameterNotNull(type, "type", string.Empty);
111+
Guard.IsNotNull(type, "type", string.Empty);
112112
object? o;
113113
if (parameterTypes != null)
114114
{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
6+
namespace Microsoft.VisualStudio.TestTools.UnitTesting;
7+
8+
/// <summary>
9+
/// A guard helper class to help validate preconditions.
10+
/// </summary>
11+
internal static class Guard
12+
{
13+
internal static void IsNotNull(object? param, string parameterName, string? message)
14+
{
15+
if (param is not null)
16+
{
17+
return;
18+
}
19+
20+
if (message is null)
21+
{
22+
throw new ArgumentNullException(parameterName);
23+
}
24+
25+
throw new ArgumentNullException(parameterName, message);
26+
}
27+
28+
internal static void IsNotNullOrEmpty(string? argument, string parameterName, string message)
29+
{
30+
if (StringEx.IsNullOrEmpty(argument))
31+
{
32+
throw new ArgumentException(message, parameterName);
33+
}
34+
}
35+
}

src/TestFramework/TestFramework/Internal/Helper.cs

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)