public void RegisterExceptionEditorで登録したエディタで例外を編集できる() { // setup FixtureBook fixtureBook = new FixtureBook(); // when fixtureBook.RegisterExceptionEditor((SystemException e) => { Console.WriteLine(e); Assert.AreEqual("sys", e.Message); return(new Dictionary <string, string>() { { "Message", "zzz" } }); }); fixtureBook.RegisterExceptionEditor <ApplicationException>(e => { Console.WriteLine(e); Assert.AreEqual("app", e.Message); return(new Dictionary <string, string>() { { "Message", "zzz" } }); }); // then fixtureBook.Validate <SystemException>(() => { throw new SystemException("sys"); }, "Exception"); fixtureBook.Validate <ApplicationException>(() => { throw new ApplicationException("app"); }, "Exception"); }
public void RegisterDefaultExceptionEditorで登録したエディタはRegisterExceptionEditorで上書きできる() { // when FixtureBook.RegisterDefaultExceptionEditor <ApplicationException>(e => { Console.WriteLine(e); Assert.AreEqual("app", e.Message); return(new Dictionary <string, string>() { { "Message", "ZZZ" } }); }); FixtureBook fixtureBook = new FixtureBook(); fixtureBook.RegisterExceptionEditor <ApplicationException>(e => { Console.WriteLine(e); Assert.AreEqual("app", e.Message); return(new Dictionary <string, string>() { { "Message", "zzz" } }); }); // then fixtureBook.Validate <ApplicationException>(() => { throw new ApplicationException("app"); }, "Exception"); }