forked from smartstore/SmartStoreNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeAssert.cs
More file actions
36 lines (32 loc) · 1.22 KB
/
Copy pathTypeAssert.cs
File metadata and controls
36 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using NUnit.Framework;
namespace SmartStore.Tests
{
public static class TypeAssert
{
public static void AreEqual(object expected, object instance)
{
if (expected == null)
Assert.IsNull(instance);
else
Assert.IsNotNull(instance, "Instance was null");
Assert.AreEqual(expected.GetType(), instance.GetType(), "Expected: " + expected.GetType() + ", was: " + instance.GetType() + " was not of type " + instance.GetType());
}
public static void AreEqual(Type expected, object instance)
{
if (expected == null)
Assert.IsNull(instance);
else
Assert.IsNotNull(instance, "Instance was null");
Assert.AreEqual(expected, instance.GetType(), "Expected: " + expected.GetType() + ", was: " + instance.GetType() + " was not of type " + instance.GetType());
}
public static void Equals<T>(object instance)
{
AreEqual(typeof(T), instance);
}
public static void Is<T>(object instance)
{
Assert.IsTrue(instance is T, "Instance " + instance + " was not of type " + typeof(T));
}
}
}