示例#1
0
        public void PopulatedListMonadLaw(Law <TestArgs <ListF, string, int, long> > law)
        {
            var args = TestArgs.Default <ListF>();

            args.LiftedA = new List <string> {
                args.A
            }.K();
            args.LiftedB = new List <int> {
                args.B
            }.K();
            args.LiftedFuncAtoB = new List <Func <string, int> > {
                args.FuncAtoB
            }.K();
            args.LiftedFuncBtoC = new List <Func <int, long> > {
                args.FuncBtoC
            }.K();
            args.FuncAtoLiftedB = a => new List <int> {
                args.FuncAtoB(a)
            }.K();
            args.FuncBtoLiftedC = b => new List <long> {
                args.FuncBtoC(b)
            }.K();

            law.TestLaw(args).ShouldBe(true);
        }
示例#2
0
        public void OkFunctorLaw(Law <TestArgs <ResultOkF <bool>, string, int, long> > law)
        {
            var args = TestArgs.Default <ResultOkF <bool> >();

            args.LiftedA = Ok(args.A).K <string, bool>();

            law.TestLaw(args).ShouldBe(true);
        }
示例#3
0
        public void ErrorInvariantLaw(Law <TestArgs <ResultOkF <bool>, string, int, long> > law)
        {
            var args = TestArgs.Default <ResultOkF <bool> >();

            args.LiftedA = Error(false).K <string, bool>();

            law.TestLaw(args).ShouldBe(true);
        }
示例#4
0
        public void SuccessFunctorLaw(Law <TestArgs <TryF, string, int, long> > law)
        {
            var args = TestArgs.Default <TryF>();

            args.LiftedA = new Success <string>(args.A);

            law.TestLaw(args).ShouldBe(true);
        }
示例#5
0
        public void FailureFunctorLaw(Law <TestArgs <TryF, string, int, long> > law)
        {
            var args = TestArgs.Default <TryF>();

            args.LiftedA = GetFailure <string>().K();

            law.TestLaw(args).ShouldBe(true);
        }
示例#6
0
        public void SomeFunctorLaw(Law <TestArgs <OptionF, string, int, long> > law)
        {
            var args = TestArgs.Default <OptionF>();

            args.LiftedA = Some(args.A);

            law.TestLaw(args).ShouldBe(true);
        }
示例#7
0
        public void EmptyListFunctorLaw(Law <TestArgs <ListF, string, int, long> > law)
        {
            var args = TestArgs.Default <ListF>();

            args.LiftedA = new List <string>().K();

            law.TestLaw(args).ShouldBe(true);
        }
示例#8
0
        public void NoneInvariantLaw(Law <TestArgs <OptionF, string, int, long> > law)
        {
            var args = TestArgs.Default <OptionF>();

            args.LiftedA = None.K <string>();

            law.TestLaw(args).ShouldBe(true);
        }
示例#9
0
        public void PopulatedListInvariantLaw(Law <TestArgs <ListF, string, int, long> > law)
        {
            var args = TestArgs.Default <ListF>();

            args.LiftedA = new List <string> {
                args.A
            }.K();

            law.TestLaw(args).ShouldBe(true);
        }
示例#10
0
        public void OkApplyLaw(Law <TestArgs <ResultOkF <bool>, string, int, long> > law)
        {
            var args = TestArgs.Default <ResultOkF <bool> >();

            args.LiftedA        = Ok(args.A).K <string, bool>();
            args.LiftedB        = Ok(args.B).K <int, bool>();
            args.LiftedFuncAtoB = Ok(args.FuncAtoB).K <Func <string, int>, bool>();
            args.LiftedFuncBtoC = Ok(args.FuncBtoC).K <Func <int, long>, bool>();

            law.TestLaw(args).ShouldBe(true);
        }
示例#11
0
        public void ErrorApplyLaw(Law <TestArgs <ResultOkF <bool>, string, int, long> > law)
        {
            var args = TestArgs.Default <ResultOkF <bool> >();

            args.LiftedA        = Error(false).K <string, bool>();
            args.LiftedB        = Error(false).K <int, bool>();
            args.LiftedFuncAtoB = Error(false).K <Func <string, int>, bool>();
            args.LiftedFuncBtoC = Error(false).K <Func <int, long>, bool>();

            law.TestLaw(args).ShouldBe(true);
        }
示例#12
0
        public void SuccessApplicativeLaw(Law <TestArgs <TryF, string, int, long> > law)
        {
            var args = TestArgs.Default <TryF>();

            args.LiftedA        = new Success <string>(args.A);
            args.LiftedB        = new Success <int>(args.B);
            args.LiftedFuncAtoB = new Success <Func <string, int> >(args.FuncAtoB);
            args.LiftedFuncBtoC = new Success <Func <int, long> >(args.FuncBtoC);

            law.TestLaw(args).ShouldBe(true);
        }
示例#13
0
        public void EmptyListApplyLaw(Law <TestArgs <ListF, string, int, long> > law)
        {
            var args = TestArgs.Default <ListF>();

            args.LiftedA        = new List <string>().K();
            args.LiftedB        = new List <int>().K();
            args.LiftedFuncAtoB = new List <Func <string, int> >().K();
            args.LiftedFuncBtoC = new List <Func <int, long> >().K();

            law.TestLaw(args).ShouldBe(true);
        }
示例#14
0
        public void SomeApplyLaw(Law <TestArgs <OptionF, string, int, long> > law)
        {
            var args = TestArgs.Default <OptionF>();

            args.LiftedA        = Some(args.A);
            args.LiftedB        = Some(args.B);
            args.LiftedFuncAtoB = Some(args.FuncAtoB);
            args.LiftedFuncBtoC = Some(args.FuncBtoC);

            law.TestLaw(args).ShouldBe(true);
        }
示例#15
0
        public void NoneApplyLaw(Law <TestArgs <OptionF, string, int, long> > law)
        {
            var args = TestArgs.Default <OptionF>();

            args.LiftedA        = None.K <string>();
            args.LiftedB        = None.K <int>();
            args.LiftedFuncAtoB = None.K <Func <string, int> >();
            args.LiftedFuncBtoC = None.K <Func <int, long> >();

            law.TestLaw(args).ShouldBe(true);
        }
示例#16
0
        public void FailureApplyLaw(Law <TestArgs <TryF, string, int, long> > law)
        {
            var args = TestArgs.Default <TryF>();

            args.LiftedA        = GetFailure <string>().K();
            args.LiftedB        = GetFailure <int>().K();
            args.LiftedFuncAtoB = GetFailure <Func <string, int> >().K();
            args.LiftedFuncBtoC = GetFailure <Func <int, long> >().K();

            law.TestLaw(args).ShouldBe(true);
        }
示例#17
0
        public void SuccessMonadLaw(Law <TestArgs <TryF, string, int, long> > law)
        {
            var args = TestArgs.Default <TryF>();

            args.LiftedA        = new Success <string>(args.A);
            args.LiftedB        = new Success <int>(args.B);
            args.LiftedFuncAtoB = new Success <Func <string, int> >(args.FuncAtoB);
            args.LiftedFuncBtoC = new Success <Func <int, long> >(args.FuncBtoC);
            args.FuncAtoLiftedB = a => new Success <int>(args.FuncAtoB(a));
            args.FuncBtoLiftedC = b => new Success <long>(args.FuncBtoC(b));

            law.TestLaw(args).ShouldBe(true);
        }