Пример #1
0
        public void LeafIsNotNode()
        {
            var sut    = new RoseLeaf <bool, double>(-4);
            var actual = sut.IsNode();

            Assert.False(actual.ToBool());
        }
Пример #2
0
        public void MatchLeaf()
        {
            IRoseTree <string, int> tree = new RoseLeaf <string, int>(42);
            int actual = tree.Accept(new MatchIntLeafVisitor());

            Assert.Equal(42, actual);
        }
Пример #3
0
        public void LeafIsLeaf()
        {
            var sut    = new RoseLeaf <bool, double>(2);
            var actual = sut.IsLeaf();

            Assert.True(actual.ToBool());
        }
Пример #4
0
        public void CataLeaf()
        {
            IRoseTree <string, int> tree = new RoseLeaf <string, int>(42);
            int actual = tree.Cata((x, xs) => x.Length + xs.Sum(), x => x);

            Assert.Equal(42, actual);
        }