コード例 #1
0
        protected override void TestSingleResult(ResultOrError <int> result)
        {
            result.Bind(() => ResultOrError <int> .Success());
            result.Bind(() => Result <int, int> .Success(100));
            result.Bind(() => Result <int, int> .Success(101), error => Result <int, int> .Error(500));
            result.BindOnError(error => ResultOrError <int> .Error(500));
            result.BindOnError(error => Result.Error());

            result.OnSuccess(() => { });
            result.OnSuccess(() => 101);
            result.OnError(error => { });
            result.OnError(error => 500);

            result.Either(() => { }, error => { });
            result.Either(() => 101, error => { });
            result.Either(() => { }, error => 500);
            result.Either(() => 101, error => 500);

            result.Ensure(() => true, () => 500);
            result.Match(() => true, error => false);
        }
コード例 #2
0
        protected override void TestLargeContent(ResultOrError <string> result)
        {
            result.Bind(() => ResultOrError <string> .Success());
            result.Bind(() => Result <string, string> .Success(LargeContent));
            result.Bind(() => Result <string, string> .Success(LargeContent), error => Result <string, string> .Error(error));
            result.BindOnError(error => ResultOrError <string> .Error(error));
            result.BindOnError(error => Result <string, string> .Error(error));

            result.OnSuccess(() => { });
            result.OnSuccess(() => LargeContent);
            result.OnError(error => { });
            result.OnError(error => error);

            result.Either(() => { }, error => { });
            result.Either(() => LargeContent, error => { });
            result.Either(() => { }, error => error);
            result.Either(() => LargeContent, error => error);

            result.Ensure(() => true, () => LargeContent);
            result.Match(() => LargeContent, error => error);
        }