Exemple #1
0
        public void Match_WithFuncCtnDefaultValue_CallsFuncCtnT()
        {
            Pipe <int> pipe = new Ctn <int>(DefaultValue, None);

            var fnCtnT     = Substitute.For <Func <Ctn <int>, Unit> >();
            var fnCtnError = Substitute.For <Func <Ctn <ExceptionDispatchInfo>, Unit> >();

            pipe.Match(fnCtnT, fnCtnError);

            fnCtnT.Received()(Arg.Any <Ctn <int> >());
            fnCtnError.DidNotReceive();
        }
Exemple #2
0
        public void Match_WithFuncCtnDefaultValue_ReturnsFuncOutput()
        {
            Pipe <int> pipe = new Ctn <int>(DefaultValue, None);

            var fnCtnError = Substitute.For <Func <Ctn <ExceptionDispatchInfo>, string> >();

            const string resultText = "some result";
            var          result     = pipe.Match(ctnInt => resultText, fnCtnError);

            result.Should().Be(resultText);

            fnCtnError.DidNotReceive();
        }
Exemple #3
0
        public void Match_WithFuncCtnError_CallsFuncCtnError()
        {
            var        exInfo = ExceptionDispatchInfo.Capture(new ApplicationException("test error"));
            Pipe <int> pipe   = new Ctn <ExceptionDispatchInfo>(exInfo, None);

            var fnCtnT     = Substitute.For <Func <Ctn <int>, Unit> >();
            var fnCtnError = Substitute.For <Func <Ctn <ExceptionDispatchInfo>, Unit> >();

            pipe.Match(fnCtnT, fnCtnError);

            fnCtnT.DidNotReceive();
            fnCtnError.Received()(Arg.Any <Ctn <ExceptionDispatchInfo> >());
        }
Exemple #4
0
        public void Match_WithFuncCtnDefaultValueNull_ThrowsArgNullException()
        {
            Pipe <int> pipe = new Ctn <int>(DefaultValue, None);

            var fnCtnError = Substitute.For <Func <Ctn <ExceptionDispatchInfo>, Unit> >();

            Action call = () => pipe.Match(null, fnCtnError);

            call.Should().ThrowExactly <ArgumentNullException>()
            .Which
            .ParamName.Should().Be("containerOfValue");

            fnCtnError.DidNotReceive();
        }
Exemple #5
0
        public void Match_WithFuncCtnError_ReturnsFuncOutput()
        {
            var        exInfo = ExceptionDispatchInfo.Capture(new ApplicationException("test error"));
            Pipe <int> pipe   = new Ctn <ExceptionDispatchInfo>(exInfo, None);

            var fnCtnT = Substitute.For <Func <Ctn <int>, string> >();

            const string resultText = "some result";
            var          result     = pipe.Match(fnCtnT, ctnError => resultText);

            result.Should().Be(resultText);

            fnCtnT.DidNotReceive();
        }
Exemple #6
0
        public void Match_WithFuncCtnErrorNull_ThrowsArgNullException()
        {
            var        exInfo = ExceptionDispatchInfo.Capture(new ApplicationException("test error"));
            Pipe <int> pipe   = new Ctn <ExceptionDispatchInfo>(exInfo, None);

            var fnCtnT = Substitute.For <Func <Ctn <int>, Unit> >();

            Action call = () => pipe.Match(fnCtnT, null);

            call.Should().ThrowExactly <ArgumentNullException>()
            .Which
            .ParamName.Should().Be("containerOfError");

            fnCtnT.DidNotReceive();
        }