forked from ducas/MFUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssertTests.cs
94 lines (80 loc) · 2.69 KB
/
AssertTests.cs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using Microsoft.SPOT;
namespace MFUnit.Tests
{
public class AssertTests
{
public void AssertIsNull_ShouldPass_WhenActualIsNull()
{
Assert.IsNull(null);
}
public void AssertIsNull_ShouldFail_WhenActualIsNotNull()
{
Assert.Throws(() => Assert.IsNull(1), typeof(AssertException));
}
public void AssertIsNotNull_ShouldPass_WhenActualIsNotNull()
{
Assert.IsNotNull(1);
}
public void AssertIsNotNull_ShouldFail_WhenActualIsNull()
{
Assert.Throws(() => Assert.IsNotNull(null), typeof(AssertException));
}
public void AssertIsTrue_ShouldPass_WhenActualIsTrue()
{
Assert.IsTrue(true);
}
public void AssertIsTrue_ShouldFail_WhenActualIsNull()
{
Assert.Throws(() => Assert.IsTrue(false), typeof(AssertException));
}
public void AssertIsFalse_ShouldPass_WhenActualIsFalse()
{
Assert.IsFalse(false);
}
public void AssertIsFalse_ShouldFail_WhenActualIsNull()
{
Assert.Throws(() => Assert.IsFalse(true), typeof(AssertException));
}
public void AssertFail_ShouldThrowException()
{
Assert.Throws(() => Assert.Fail("test"), typeof(AssertException));
}
public void AssertAreEqual_ShouldPass_WhenExpectedAndActualEqual()
{
Assert.AreEqual(1, 1);
}
public void AssertAreEqual_ShouldFail_WhenExpectedAndActualNotEqual()
{
Assert.Throws(() => Assert.AreEqual(1, 2), typeof(AssertException));
}
public void AssertThrows_ShouldPass_WhenExpectedExceptionThrown()
{
Assert.Throws(() => { throw new NotImplementedException(); }, typeof(NotImplementedException));
}
public void AssertThrows_ShouldFail_WhenExpectedExceptionThrown()
{
try
{
Assert.Throws(() => { return; }, typeof(NotImplementedException));
}
catch (AssertException)
{
return;
}
Assert.Fail("Assert.Throws did not fail when no exception was thrown.");
}
public void AssertThrows_ShouldOnlyCatchExpectedException()
{
try
{
Assert.Throws(() => { throw new NotImplementedException(); }, typeof(ArgumentException));
}
catch (NotImplementedException)
{
return;
}
Assert.Fail("NotImplementedException was caught by Assert.Throws when ArgumentException was specified.");
}
}
}