Пример #1
0
        public void Match2CasesTest()
        {
            var union = new DiscriminatedUnion <string, bool>("ok");

            Assert.True(union.Match(
                            s => true,
                            b => false
                            ));
        }
Пример #2
0
        public void Match4CasesTest()
        {
            var union = new DiscriminatedUnion <string, bool, int, long>(8L);

            Assert.Throws <Exception>(() =>
            {
                union.Match(
                    s => true,
                    b => false
                    );
            });

            Assert.True(union.Match(
                            s => false,
                            b => false,
                            i => false,
                            l => true
                            ));
        }
Пример #3
0
        public void Match3CasesTest()
        {
            var union = new DiscriminatedUnion <string, bool, int>(true);

            var fail = true;

            var r = union.Match(
                s => fail = true,
                b => fail = false,
                i => fail = true
                );

            Assert.False(fail);
            Assert.False(r);
        }