public void ThenTryTIn_WhenExecuteIsNull_ThrowsArgumentNullException() { TryResult <int> t = ""; Func <int, TryResult> t2 = null; Assert.Throws <ArgumentNullException>(() => t.ThenTry(t2)); }
public void ThenTryTOut_WhenTryFailed_ReturnsOriginalError() { TryResult t = "err"; var t2 = t.ThenTry <int>(() => 1); Assert.AreEqual(t.ErrorMessage, t2.ErrorMessage); }
public void ThenTry_WhenTryFailed_ReturnsOriginalError() { TryResult t = "err"; var t2 = t.ThenTry(() => TryResult.Succeed()); Assert.AreEqual(t, t2); }
public void ThenTryTInTOut_WhenTryFailed_ReturnsOriginalError() { TryResult <int> t = "err"; var t2 = t.ThenTry <int, int>(r => 1); Assert.AreEqual(t.Result, t2.Result); }
public void ThenTryTIn_WhenTrySucceededAndExecutorSucceeds_ReturnsResultOfOriginalTry() { TryResult <int> t = 1; var tr = t.ThenTry(r => TryResult.Succeed()); Assert.AreEqual(t, tr); }
public void ThenTryTInTOut_WhenTrySucceededAndExecutorSucceeds_ReturnsResultOfExecutor() { TryResult <int> t = 1; var result = 5; var tr = t.ThenTry <int, int>(r => result); Assert.AreEqual(result, tr.Result); }
public void ThenTryTInTOut_WhenTrySucceededAndExecutorFails_ReturnsExecutorError() { TryResult <int> t = 1; var err = "err"; var tr = t.ThenTry <int, int>(r => err); Assert.AreEqual(err, tr.ErrorMessage); }
public void ThenTryTOut_WhenTryFailed_DoesNotExecute() { TryResult t = "err"; var executed = false; t.ThenTry <int>(() => { executed = true; return(1); }); Assert.IsFalse(executed); }
public void ThenTry_WhenTryFailed_DoesNotExecute() { TryResult t = "err"; var executed = false; t.ThenTry(() => { executed = true; return(TryResult.Succeed()); }); Assert.IsFalse(executed); }
public void ThenTryTInTOut_WhenTrySucceeded_Executes() { TryResult <int> t = 1; var executed = false; t.ThenTry <int, int>(r => { executed = true; return(1); }); Assert.IsTrue(executed); }
public void ThenTryTIn_WhenTrySucceeded_Executes() { TryResult <int> t = 1; var executed = false; t.ThenTry(() => { executed = true; return(TryResult.Succeed()); }); Assert.IsTrue(executed); }
public void ThenTryTOut_WhenTryResultIsNull_ThrowsArgumentNullException() { TryResult t = null; Assert.Throws <ArgumentNullException>(() => t.ThenTry <int>(() => 1)); }
public void ThenTryTOut_WhenExecuteIsNull_ThrowsArgumentNullException() { TryResult t = ""; Assert.Throws <ArgumentNullException>(() => t.ThenTry <int>(null)); }
public void ThenTry_WhenTryResultIsNull_ThrowsArgumentNullException() { TryResult t = null; Assert.Throws <ArgumentNullException>(() => t.ThenTry(() => string.Empty)); }
public void ThenTryTIn_WhenExecuteResultIsNull_ThrowsInvalidOperationException() { TryResult <int> t = 1; Assert.Throws <InvalidOperationException>(() => t.ThenTry(r => null)); }