diff options
Diffstat (limited to 'src/Notepad/Test')
| -rw-r--r-- | src/Notepad/Test/Call.cs | 37 | ||||
| -rw-r--r-- | src/Notepad/Test/Extensions/AssertionExtensions.cs | 35 |
2 files changed, 72 insertions, 0 deletions
diff --git a/src/Notepad/Test/Call.cs b/src/Notepad/Test/Call.cs new file mode 100644 index 0000000..67ab49c --- /dev/null +++ b/src/Notepad/Test/Call.cs @@ -0,0 +1,37 @@ +using System;
+using System.Linq.Expressions;
+
+namespace Notepad.Test {
+ public class Call {
+ public static IActionRecorder To(Expression<Action> actionToRecord) {
+ return new ActionRecorder(actionToRecord.Compile());
+ }
+ }
+
+ public class ActionRecorder : IActionRecorder {
+ private readonly Action actionToRecord;
+
+ public ActionRecorder(Action actionToRecord) {
+ this.actionToRecord = actionToRecord;
+ }
+
+ public Action ActionToRecord() {
+ return actionToRecord;
+ }
+ }
+
+ public interface IActionRecorder {
+ Action ActionToRecord();
+ }
+
+ public static class ActionRecorderExtensions {
+ public static void ShouldThrow<ThisException>(this IActionRecorder recorder) where ThisException : Exception {
+ try {
+ recorder.ActionToRecord()();
+ }
+ catch (ThisException) {
+ return;
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/src/Notepad/Test/Extensions/AssertionExtensions.cs b/src/Notepad/Test/Extensions/AssertionExtensions.cs new file mode 100644 index 0000000..980d325 --- /dev/null +++ b/src/Notepad/Test/Extensions/AssertionExtensions.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic;
+using System.Linq;
+using MbUnit.Framework;
+
+namespace Notepad.Test.Extensions {
+ public static class AssertionExtensions {
+ public static void ShouldBeEqualTo<T>(this T itemToValidate, T expectedValue) {
+ Assert.AreEqual(expectedValue, itemToValidate);
+ }
+
+ public static void ShouldBeSameInstanceAs<T>(this T left, T right) {
+ Assert.IsTrue(ReferenceEquals(left, right));
+ }
+
+ public static void ShouldNotBeNull<T>(this T itemToCheck) where T : class {
+ Assert.IsNotNull(itemToCheck);
+ }
+
+ public static void ShouldBeGreaterThan(this int actual, int expected) {
+ Assert.GreaterThan(actual, expected);
+ }
+
+ public static void ShouldBeLessThan(this int actual, int expected) {
+ Assert.Less(actual, expected);
+ }
+
+ public static void ShouldContain<T>(this IEnumerable<T> itemsToPeekInto, T itemToLookFor) {
+ Assert.IsTrue(itemsToPeekInto.Contains(itemToLookFor));
+ }
+
+ public static void ShouldNotContain<T>(this IEnumerable<T> itemsToPeekInto, T itemToLookFor) {
+ Assert.IsFalse(itemsToPeekInto.Contains(itemToLookFor));
+ }
+ }
+}
\ No newline at end of file |
