mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-19 23:28:15 +08:00
53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Dapper.Contrib.Tests_NET45
|
|
{
|
|
/// <summary>
|
|
/// Assert extensions borrowed from Sam's code in DapperTests
|
|
/// </summary>
|
|
static class Assert
|
|
{
|
|
public static void IsEqualTo<T>(this T obj, T other)
|
|
{
|
|
if (!obj.Equals(other))
|
|
{
|
|
throw new ApplicationException(string.Format("{0} should be equals to {1}", obj, other));
|
|
}
|
|
}
|
|
|
|
public static void IsSequenceEqualTo<T>(this IEnumerable<T> obj, IEnumerable<T> other)
|
|
{
|
|
if (!obj.SequenceEqual(other))
|
|
{
|
|
throw new ApplicationException(string.Format("{0} should be equals to {1}", obj, other));
|
|
}
|
|
}
|
|
|
|
public static void IsFalse(this bool b)
|
|
{
|
|
if (b)
|
|
{
|
|
throw new ApplicationException("Expected false");
|
|
}
|
|
}
|
|
|
|
public static void IsTrue(this bool b)
|
|
{
|
|
if (!b)
|
|
{
|
|
throw new ApplicationException("Expected true");
|
|
}
|
|
}
|
|
|
|
public static void IsNull(this object obj)
|
|
{
|
|
if (obj != null)
|
|
{
|
|
throw new ApplicationException("Expected null");
|
|
}
|
|
}
|
|
|
|
}
|
|
} |