public void Ok_Success() { Result <int, string> wrappedResult = new Success <int, string>(10); var guard = new ResultGuard <int, string, int>(wrappedResult); var result = guard.Default(i => i * 2).Do(); Assert.AreEqual(result, 20); }
public void Ok_Failure_FallsThroughToDefault() { Result <int, string> wrappedResult = new Failure <int, string>("Error"); var guard = new ResultGuard <int, string, string>(wrappedResult); guard.Where(i => i == string.Empty, i => "no match"); guard.Where(i => i == string.Empty, i => "no match"); guard.Default((string i) => "match"); var result = guard.Do(); Assert.AreEqual(result, "match"); }
public void Ok_Success_FallsThroughToDefault() { Result <int, string> wrappedResult = new Success <int, string>(10); var guard = new ResultGuard <int, string, string>(wrappedResult); guard.Where(i => i == 11, i => "no match"); guard.Where(i => i == 11, i => "no match"); guard.Default((int i) => "match"); var result = guard.Do(); Assert.AreEqual(result, "match"); }