public void SetContext_should_work_with_non_serializabl_context_item() { var ex = new Exception(); ex.SetContext("context", new {name="non-serializable"}); }
public void SetContext_should_work_with_null_context_item() { var ex = new Exception(); ex.SetContext("context", null); }
public void given_NonSerializableWrapper_only_context_is_printed() { var ex = new Exception("some ex"); ex.SetContext("addl message", "some addl message"); ex.SetContext("non-serializable-obj", new ObjectWithPublicFields{Id = 5, TestInteger = 10, TestString = "string"}); var expected = @"[Exception]: hashcode { $ignore$ } { Message : some ex StackTrace : {NULL} Source : {NULL} TargetSite : {NULL} HelpLink : {NULL} HResult : -2146233088 Data : [ListDictionaryInternal]: hashcode { $ignore$ } { addl message : some addl message non-serializable-obj : [ObjectWithPublicFields]: hashcode { $ignore$ } { Id : 5 TestInteger : 10 TestString : string } } InnerException : {NULL} }"; shouldBeSame(expected, ex); }