master
 1using System;
 2using System.Linq.Expressions;
 3
 4namespace Notepad.Test {
 5    public class Call {
 6        public static IActionRecorder To(Expression<Action> actionToRecord) {
 7            return new ActionRecorder(actionToRecord.Compile());
 8        }
 9    }
10
11    public class ActionRecorder : IActionRecorder {
12        private readonly Action actionToRecord;
13
14        public ActionRecorder(Action actionToRecord) {
15            this.actionToRecord = actionToRecord;
16        }
17
18        public Action ActionToRecord() {
19            return actionToRecord;
20        }
21    }
22
23    public interface IActionRecorder {
24        Action ActionToRecord();
25    }
26
27    public static class ActionRecorderExtensions {
28        public static void ShouldThrow<ThisException>(this IActionRecorder recorder) where ThisException : Exception {
29            try {
30                recorder.ActionToRecord()();
31            }
32            catch (ThisException) {
33                return;
34            }
35        }
36    }
37}