diff options
| author | mo <mo.khan@gmail.com> | 2018-11-04 15:22:16 -0700 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2018-11-04 15:22:16 -0700 |
| commit | 5ee1f55497a4e30322a56f133f897ecde1612967 (patch) | |
| tree | bf544e0879234c3623869627d8786776cb19b8e9 /src/Notepad/Test/Call.cs | |
Diffstat (limited to 'src/Notepad/Test/Call.cs')
| -rw-r--r-- | src/Notepad/Test/Call.cs | 37 |
1 files changed, 37 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 |
