public void GenericErrorResult_AssertionCallbackIsCalled() { var input = ActResult.ThrewException <int>(new Exception()); var underTest = new Acted <int>(input); bool called = false; underTest.Assert(r => called = true); Assert.IsTrue(called); }
public void GenericErrorResult_EmptyAssertReturnsAssertionRoot() { var input = ActResult.ThrewException <int>(new Exception()); var underTest = new Acted <int>(input); var result = underTest.Assert(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(AssertionRoot)); }
public void GenericErrorResult_ThrewExceptionDoesNotThrowException() { var result = ActResult.ThrewException <int>(new Exception()); var underTest = new AssertionRoot <int>(result); Exception exception = null; try { underTest.ThrewException(); } catch (Exception ex) { exception = ex; } Assert.IsNull(exception); }
public void GenericErrorResult_IsSuccessThrowsException() { var result = ActResult.ThrewException <int>(new Exception()); var underTest = new AssertionRoot <int>(result); Exception exception = null; try { underTest.IsSuccess(); } catch (Exception ex) { exception = ex; } Assert.IsNotNull(exception); Assert.IsInstanceOfType(exception, typeof(AssertFailedException)); }
public void ErrorResult_IsSuccessThrowsExceptionWithMessage() { const string message = "Should work"; var result = ActResult.ThrewException(new Exception()); var underTest = new AssertionRoot(result); Exception exception = null; try { underTest.IsSuccess(message); } catch (Exception ex) { exception = ex; } Assert.IsTrue(exception.Message.Contains(message)); }
public void GenericErrorResult_ValidateThrowsException() { var result = ActResult.ThrewException <int>(new IOException()); var underTest = new AssertionRoot <int>(result); Exception exception = null; try { underTest.Validate(r => Assert.AreEqual(1, r)); } catch (Exception ex) { exception = ex; } Assert.IsNotNull(exception); Assert.IsInstanceOfType(exception, typeof(AssertFailedException)); }
public void GenericErrorResultWithWrongExceptionType_ThrewExceptionThrowsException() { var result = ActResult.ThrewException <int>(new IOException()); var underTest = new AssertionRoot <int>(result); Exception exception = null; try { underTest.ThrewException <InvalidOperationException>(); } catch (Exception ex) { exception = ex; } Assert.IsNotNull(exception); Assert.IsInstanceOfType(exception, typeof(AssertFailedException)); }
public void ErrorResultWithWrongExceptionType_ThrewExceptionThrowsExceptionWithMessage() { const string message = "Should throw InvalidOperation"; var result = ActResult.ThrewException(new IOException()); var underTest = new AssertionRoot(result); Exception exception = null; try { underTest.ThrewException <InvalidOperationException>(message); } catch (Exception ex) { exception = ex; } Assert.IsNotNull(exception); Assert.IsInstanceOfType(exception, typeof(AssertFailedException)); }