public void TryCatchNoExceptionTest() { bool exception_occured = false; Flux.Try(() => { }).Catch <Exception>(ex => { exception_occured = true; }); Assert.IsFalse(exception_occured); }
public void TryCatchExcutedTest() { bool exception_occured = false; Flux.Try(() => { throw new NotImplementedException(); }) .Catch <NotImplementedException>(ex => { exception_occured = true; }); Assert.IsTrue(exception_occured); }
public void Test_Try_4_Catch_CatchExcuted_ByCorrectOrder() { bool exception_occured = false; Flux.Try(() => { throw new NotImplementedException(); }) .Catch <NotImplementedException, Exception>(ex1 => { exception_occured = true; }, ex2 => { }); // catch more than one Assert.IsTrue(exception_occured); }
public void TryCatchTest() { var result = 0; Flux.Try(() => { throw new NotImplementedException(); result = 10; }).Catch(exception => { result = 20; }); Assert.AreEqual(20, result); }
public void TrySwallowIfTest4() { int result = 0; Flux.Try(() => { throw new ArithmeticException(); ++result; }).SwallowIf <NullReferenceException, OutOfMemoryException, ArithmeticException, IndexOutOfRangeException>(); Assert.AreEqual(result, 0); }
public void TrySwallowIfTest2() { int result = 0; Flux.Try(() => { throw new NullReferenceException(); ++result; }).SwallowIf <NullReferenceException, ArgumentException>(); Assert.AreEqual(result, 0); }
public void TrySwallowTest() { var result = 0; Flux.Try(() => { throw new NotImplementedException(); ++result; }).Swallow(); Assert.AreEqual(0, result); }
public void TrySwallowIfUnmatchedTest() { int result = 0; Flux.Try(() => { throw new NotImplementedException(); ++result; }).SwallowIf <NullReferenceException>(); Assert.AreEqual(result, 0); }