Skip to content

Commit f181d6f

Browse files
committed
- additional assertion methods added
- MsBuild base class to always show Logger output
1 parent 6912204 commit f181d6f

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

Core.Common.Standard/Extension/AssertionExtensions.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,45 @@ public static IEnumerable<T> AssertContains<T>(this IEnumerable<T> collection, T
154154
return collection;
155155
}
156156

157+
[DebuggerHidden]
158+
public static IList<T> AssertContains<T>(this IList<T> collection, T item, string argumentName = "", string message = DefaultMessage)
159+
{
160+
((IEnumerable<T>)collection).AssertContains(item, argumentName, message);
161+
return collection;
162+
}
163+
164+
[DebuggerHidden]
165+
public static List<T> AssertContains<T>(this List<T> collection, T item, string argumentName = "", string message = DefaultMessage)
166+
{
167+
((IEnumerable<T>)collection).AssertContains(item, argumentName, message);
168+
return collection;
169+
}
170+
157171
[DebuggerHidden]
158172
public static IEnumerable<T> AssertIsNotNullOrEmpty<T>(this IEnumerable<T> collection, string argumentName = "", string message = DefaultMessage)
159173
{
160174
collection.AssertIsNotNull(argumentName);
161-
if (collection.Any())
175+
if (!collection.Any())
162176
{
163177
throw new InvalidOperationException(message == DefaultMessage ? argumentName + " collection have to contain any child" : message);
164178
}
165179
return collection;
166180
}
167181

182+
[DebuggerHidden]
183+
public static IList<T> AssertIsNotNullOrEmpty<T>(this IList<T> collection, string argumentName = "", string message = DefaultMessage)
184+
{
185+
((IEnumerable<T>)collection).AssertIsNotNullOrEmpty(argumentName, message);
186+
return collection;
187+
}
188+
189+
[DebuggerHidden]
190+
public static List<T> AssertIsNotNullOrEmpty<T>(this List<T> collection, string argumentName = "", string message = DefaultMessage)
191+
{
192+
((IEnumerable<T>)collection).AssertIsNotNullOrEmpty(argumentName, message);
193+
return collection;
194+
}
195+
168196
[DebuggerHidden]
169197
public static T AssertIs<T>(this T self, T expected, string argumentName = "", string message = DefaultMessage)
170198
{

Core.Common.Standard/KY.Core.Common.Standard.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<RootNamespace>KY.Core</RootNamespace>
66
<AssemblyName>KY.Core.Common</AssemblyName>
7-
<Version>4.8.0</Version>
7+
<Version>4.9.0</Version>
88
<Authors>KY-Programming</Authors>
99
<Company>KY-Programmingp</Company>
1010
<Product>KY.Core</Product>

Core.Common.Standard/MsTestBase.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace KY.Core
2+
{
3+
/// <summary>
4+
/// Enables Logger output in MsTest classes
5+
/// </summary>
6+
public abstract class MsTestBase
7+
{
8+
protected MsTestBase()
9+
{
10+
Logger.AllTargets.Add(Logger.VisualStudioOutput);
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)