-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathUnitTestUtils.cs
More file actions
48 lines (39 loc) · 1.5 KB
/
UnitTestUtils.cs
File metadata and controls
48 lines (39 loc) · 1.5 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
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (C) SomaSim LLC.
// Open source software. Please see LICENSE file for details.
using System;
namespace SomaSim
{
[AttributeUsage(AttributeTargets.Class)]
public class TestClass : Attribute
{
}
[AttributeUsage(AttributeTargets.Method)]
public class TestMethod : Attribute
{
}
public class UnitTestException : Exception
{
public UnitTestException () : base() { }
public UnitTestException (string message) : base(message) { }
public UnitTestException (string message, Exception exception) : base(message, exception) { }
}
public class Assert
{
public static void IsTrue (bool value) {
if (!value) { throw new UnitTestException("Assert.IsTrue failed"); }
}
public static void IsFalse (bool value) {
if (value) { throw new UnitTestException("Assert.IsFalse failed"); }
}
public static void IsNull (object value) {
if (value != null) { throw new UnitTestException("Assert.IsNull failed"); }
}
public static void IsNotNull (object value) {
if (value == null) { throw new UnitTestException("Assert.IsNotNull failed"); }
}
public static void IsInstanceOfType (object value, Type type) {
var valueType = (value != null) ? value.GetType() : null;
if (valueType != type) { throw new UnitTestException("Assert.IsInstanceOfType failed, expected " + type + ", got " + valueType); }
}
}
}