Esempio n. 1
0
        public void SwitchTypeNoValidCase()
        {
            bool executed = false;
            var  item     = new TypeB();

            item.Switch(
                SwitchType.Case <TypeA>(() => executed = true));
            Assert.False(executed);
        }
Esempio n. 2
0
        public void SwitchDefaultExecuted()
        {
            bool executed = false;
            var  item     = new TypeB();

            item.Switch(
                SwitchType.Case <TypeA>(() => Expression.Empty()),
                SwitchType.Default(() => executed = true));
            Assert.True(executed);
        }
Esempio n. 3
0
        public void SwitchTypeHappyFlow()
        {
            bool executed = false;
            var  item     = new TypeA();

            item.Switch(
                SwitchType.Case <TypeA>(() => executed = true),
                SwitchType.Default(() => throw new Exception("This case should not be executed.")));
            Assert.True(executed);
        }