示例#1
0
        public void RunsTakeSagaWaitingForAction()
        {
            //Arrange
            var runner     = new Saga();
            var enumerator = runner.Run(this.RootSaga());

            //Act
            SagaAction returnData = null;

            runner.OnActionEvent += (data) =>
            {
                returnData = data;
            };

            for (var i = 0; i < 100; i++)
            {
                enumerator.MoveNext();
            }

            //Assert
            Assert.IsNull(returnData);

            runner.OnAction(new SagaAction <int>("start", 11));

            for (var i = 0; i < 100; i++)
            {
                enumerator.MoveNext();
            }

            //Assert
            Assert.AreEqual("test", returnData.Type);
            Assert.AreEqual(11, returnData.GetPayload <int>());
        }
示例#2
0
    // Use this for initialization
    void Start()
    {
        var saga = new Saga();

        saga.OnActionEvent += Saga_OnActionEvent;

        this.StartCoroutine(saga.Run(this.RootSaga()));
    }
示例#3
0
        protected void RunSaga(Saga runner, IEnumerator sagaToRun)
        {
            //Arrange
            var enumerator = runner.Run(sagaToRun);

            while (enumerator.MoveNext())
            {
                ;
            }
        }
示例#4
0
        public void RunsSagaAndPutsSingleAction()
        {
            //Arrange
            var runner     = new Saga();
            var enumerator = runner.Run(this.RootSaga());

            //Act
            object returnData = null;

            runner.OnActionEvent += (data) =>
            {
                returnData = data;
            };

            while (enumerator.MoveNext())
            {
                ;
            }

            //Assert
            Assert.IsNotNull(returnData);
        }