public void GenericOkResult_IsSuccessDoesNotThrowException() { var result = ActResult.Ok(0); var underTest = new AssertionRoot <int>(result); Exception exception = null; try { underTest.IsSuccess(); } catch (Exception ex) { exception = ex; } Assert.IsNull(exception); }
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 GenericOkResult_ValidationCallbackThrowsException() { var result = ActResult.Ok(1); var underTest = new AssertionRoot <int>(result); Exception exception = null; try { underTest.Validate(r => Assert.AreEqual(2, r)); } catch (Exception ex) { exception = ex; } Assert.IsNotNull(exception); Assert.IsInstanceOfType(exception, typeof(AssertFailedException)); }
public void GenericOkResult_ValidationCallbackDoesNotThrowException() { const int one = 1; var result = ActResult.Ok(one); var underTest = new AssertionRoot <int>(result); Exception exception = null; try { underTest.Validate(r => Assert.AreEqual(one, r)); } catch (Exception ex) { exception = ex; } Assert.IsNull(exception); }
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 OkResult_ThrewExceptionThrowsException() { var result = ActResult.Ok(); var underTest = new AssertionRoot(result); Exception exception = null; try { underTest.ThrewException(); } 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)); }
public void GenericOkResult_ThrewExceptionThrowsExceptionWithMessage() { const string message = "Should not work"; var result = ActResult.Ok(0); var underTest = new AssertionRoot <int>(result); Exception exception = null; try { underTest.ThrewException(message); } catch (Exception ex) { exception = ex; } Assert.IsTrue(exception.Message.Contains(message)); }