Ejemplo n.º 1
0
        public void EventDoesNotExistsInvokesOverriddenOnError()
        {
            var errState = new ErrorState();

            var(machine, reg) = SetupCode.CreateForTests(errState);
            var msg = SetupCode.CreateMessage();

            machine.TansformState("not existing", msg, () => { errState.WasOverridden = true; /* errState.WasSet = false; */ });

            Assert.False(errState.WasSet);
            Assert.True(errState.WasOverridden);
        }
Ejemplo n.º 2
0
        public void EventFoundButTypeNotMatchingInvokesStateOnError()
        {
            var errState = new ErrorState();

            var(machine, reg) = SetupCode.CreateForTests(errState);
            var msg = SetupCode.CreateMessage();

            machine.TansformState("no-generic", msg);

            var nonGeneric = reg.First().State as StateMocks.StateWithoutGenerics;

            Assert.NotNull(nonGeneric);

            Assert.True(nonGeneric.ErrorWasSet);
        }
Ejemplo n.º 3
0
        public static (StateMachine machine, List <StateRegister> states) CreateForTests(ErrorState errorState)
        {
            var reg = new List <StateRegister>
            {
                new StateRegister("no-generic", new StateMocks.StateWithoutGenerics()),
                new StateRegister("string-generic", new StateMocks.StateWithStringParameter())
            };

            return(new StateMachine(reg, () => errorState.WasSet = true), reg);
        }