Пример #1
0
        public void MatchFilled()
        {
            IMaybe <int> sut    = new Just <int>(42);
            var          actual = sut.Accept(new MatchFilledMaybeVisitor <int>());

            Assert.Equal("42", actual);
        }
Пример #2
0
        public void SimpleQueryExpressionWorks()
        {
            IMaybe <int>    sut    = new Just <int>(42);
            IMaybe <string> actual = from i in sut
                                     select i.ToString();

            Assert.Equal(
                "42",
                actual.Accept(new FromMaybeVisitor <string>("nothing")));
        }
Пример #3
0
        public void MultiplyTwoNaturalNumbersUsingQueryExpression()
        {
            var mx = new Just <INaturalNumber>(NaturalNumber.Nine);
            var my = new Just <INaturalNumber>(NaturalNumber.Four);

            var actual = from x in mx
                         from y in my
                         select x.Multiply(y);

            Assert.Equal(
                36,
                actual
                .Accept(
                    new FromMaybeVisitor <INaturalNumber>(
                        NaturalNumber.Zero))
                .Count());
        }