예제 #1
0
        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);
        }
예제 #2
0
        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");
        }
예제 #3
0
        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");
        }