public void Safe_NotNullInstance_FunctionExecuted() { var notNull = new SafeSubject { ReferenceProperty = new Exception("msg") }; Assert.That(notNull.Safe(o => o.ReferenceProperty.Message), Is.EqualTo("msg")); }
public void Safe_CustomSafetyNotFullfiled_ChainBreaks() { var subject = new SafeSubject { ReferenceProperty = new Exception("msg", new Exception("inner msg")) }; string innerMostMessage = subject .Safe(s => s.ReferenceProperty) .Safe(p => p.InnerException, ex => ex.Message.Length > 3) .Safe(p => p.Message); Assert.That(innerMostMessage, Is.Null); }
public void Safe_SomeNullInChain_Null() { var subject = new SafeSubject { ReferenceProperty = new Exception("msg", null) }; string innerMostMessage = subject .Safe(s => s.ReferenceProperty) .Safe(p => p.InnerException) .Safe(p => p.Message); Assert.That(innerMostMessage, Is.Null); }
public void Safe_NotNullChain_InnerMostValue() { var subject = new SafeSubject { ReferenceProperty = new Exception("msg", new Exception("inner msg")) }; string innerMostMessage = subject .Safe(s => s.ReferenceProperty) .Safe(p => p.InnerException) .Safe(p => p.Message); Assert.That(innerMostMessage, Is.EqualTo("inner msg")); }
public void Safe_NullInstance_Null() { SafeSubject @null = null; Assert.That(@null.Safe(o => o.ReferenceProperty), Is.Null); }