public IEnumerable<ExceptionComparisonDifference> Compare(Exception expected, Exception actual) { if (!expected.Equals(actual)) yield return new ExceptionComparisonDifference(expected, actual, "-"); }
public virtual bool ShowErrorWasCalledWith(Exception e){ return ( e.Equals(ShowErrorParameter_e_LastCalledWith) ); }
public void CreateExceptionWithInnerReturnsCorrectResult() { // Fixture setup var value = Guid.NewGuid().ToString(); var inner = new Exception(); var expected = new Exception(); var cmd = new DelegatingGuardClauseCommand { OnCreateExceptionWithInner = (v, e) => value == v && inner.Equals(e) ? expected : new Exception() }; var sut = new ReflectionExceptionUnwrappingCommand(cmd); // Exercise system var result = sut.CreateException(value, inner); // Verify outcome Assert.Equal(expected, result); // Teardown }
internal static void Ignore(this Exception ex) { ex.Equals(ex); }
public static bool Good5(Exception x, DivideByZeroException y) { return x.Equals(y); }
public void VerifyThrowsWhenCommandThrowsUnexpectedException() { // Fixture setup var expectedInner = new Exception(); var expected = new Exception(); var cmd = new DelegatingGuardClauseCommand { OnExecute = v => { throw expectedInner; }, OnCreateExceptionWithInner = (v, e) => v == "\"Guid.Empty\"" && expectedInner.Equals(e) ? expected : new Exception(), RequestedType = typeof(Guid) }; var sut = new EmptyGuidBehaviorExpectation(); // Exercise system and verify outcome var result = Assert.Throws<Exception>(() => sut.Verify(cmd)); Assert.Equal(expected, result); // Teardown }