Ejemplo n.º 1
0
        public void ReturnTrueWhen2Rule4IsValid()
        {
            //arrange
            var flow = new Floo();

            flow.AddStateSetting("OnState").IsStartState();

            flow.AddStateSetting("ErrorState").IsEndState();

            flow.AddTransition()
            .From("OnState")
            .On("SendMessage")
            .Do(ctx => FakeFunk(ref ctx))
            .When(FakeCheck)
            .GoTo("SentState")
            .When(FakeCheck)
            .GoTo("ErrorState")
            .Otherwise()
            .GoTo("OnState");

            flow.AddTransition()
            .From("OnState")
            .On("SendSmS")
            .Do(ctx => FakeFunk(ref ctx))
            .When(FakeCheck)
            .GoTo("SentState");

            //act
            bool isValid = flow.IsValid();

            //assert
            Assert.True(isValid);
        }
Ejemplo n.º 2
0
        public void ThrowExceptionWhenSecondRuleMissingThirdEndState()
        {
            //arrange
            var wf = new Floo();

            wf.AddTransition()
            .From("State")
            .On("Command")
            .GoTo("State");

            wf.AddTransition()
            .From("OnState")
            .On("SendMessage")
            .Do(ctx => FakeFunk(ref ctx))
            .When(FakeCheck)
            .GoTo("SentState")
            .When(FakeCheck)
            .GoTo("ErrorState")
            .Otherwise()
            //.StayAt("OnState")
            ;

            //act
            Action act = () => wf.Check();

            //assert
            Assert.Throws <FloomeenException>(act);
        }
Ejemplo n.º 3
0
        public void BeTrueWhenMissingStartStateOnDeclaratioWithEventOnEnterEvent()
        {
            //arrange
            var wf = new Floo();

            wf.AddStateSetting("StartState")
            .IsStartState()
            .OnEnterEvent(FakeEnterExitCallback)
            .OnExitEvent(FakeEnterExitCallback);

            wf.AddStateSetting("EndState")
            .IsEndState()
            .OnEnterEvent(FakeEnterExitCallback);

            wf.AddTransition()
            .From("StartState")
            .On("Command")
            .GoTo("EndState");

            //act
            var isValid = wf.IsValid();

            //assert
            Assert.True(isValid);
        }
Ejemplo n.º 4
0
        public void ThrowExceptionWhenSameCommandRepeated()
        {
            //arrange
            var wf = new Floo();

            wf.AddTransition()
            .From("OnState").On("Command").GoTo("State");

            wf.AddTransition()
            .From("OnState").On("Command").GoTo("State");

            //act
            Action act = () => wf.Check();

            //assert
            Assert.Throws <FloomeenException>(act);
        }
Ejemplo n.º 5
0
        public void ThrowExceptionForInvalidSettingToStateDeclaration()
        {
            //arrange
            var wf = new Floo();

            wf.AddStateSetting("EndState").IsStartState();

            wf.AddTransition().From("State").On("Command").GoTo("EndState");

            //act
            Action act = () => wf.Check();

            //assert
            Assert.Throws <FloomeenException>(act);
        }
Ejemplo n.º 6
0
        public void ThrowExceptionWhenMissingEndStateButOnSpecified()
        {
            //arrange
            var wf = new Floo();

            wf.AddTransition()
            .From("OnState")
            .On("SendMessage");

            //act
            Action act = () => wf.Check();

            //assert
            Assert.Throws <FloomeenException>(act);
        }
Ejemplo n.º 7
0
        public void ThrowExceptionWhenMissingConditions()
        {
            //arrange
            var wf = new Floo();

            wf.AddTransition()
            .From("OnState")
            .On("SendMessage")
            .Do(ctx => FakeFunk(ref ctx));

            //act
            Action act = () => wf.Check();

            //assert
            Assert.Throws <FloomeenException>(act);
        }
Ejemplo n.º 8
0
        public void BeTrueForStartStateDeclaration()
        {
            //arrange
            var wf = new Floo();

            wf.AddStateSetting("StartState")
            .IsStartState();

            wf.AddTransition()
            .From("StartState")
            .On("Command")
            .GoTo("EndState");

            //act
            bool isValid = wf.IsValid();

            //assert
            Assert.True(isValid);
        }
Ejemplo n.º 9
0
        public void ReturnTrueWhenRule1IsValid()
        {
            //arrange
            var flow = new Floo();

            flow.AddStateSetting("OnState").IsStartState();

            flow.AddStateSetting("ErrorState").IsEndState();

            flow.AddTransition()
            .From("OnState")
            .On("SendMessage")
            .GoTo("ErrorState");

            //act
            bool isValid = flow.IsValid();

            //assert
            Assert.True(isValid);
        }