public void ActionQueueValidateEntryIsNotIn_Test()
        {
            var actionQueue = new ActionQueue <BusinessLogicEntity, BusinessLogicEntity>();
            var entry       = new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>
            {
                actionClass = new TestAction(),
                dataIn      = new TestModel
                {
                    id = 100500,
                    simulate_action_error = false,
                    is_unrecoverable      = false
                },
                execStatus = ActionExecStatus.Pending
            };

            actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>
            {
                actionClass = new TestAction(),
                dataIn      = new TestModel
                {
                    id = 100501,
                    simulate_action_error = false,
                    is_unrecoverable      = false
                },
                execStatus = ActionExecStatus.Pending
            });
            Assert.IsFalse(actionQueue.Contains(entry));
        }
        public void ActionQueueEntry_Test()
        {
            var model = new TestModel
            {
                id = 1,
                simulate_action_error = false,
                is_unrecoverable      = false
            };
            var actionQueueEntry = new ActionQueueEntry <TestModel, TestModel>()
            {
                actionClass         = new TestAction() as BusinessAction <TestModel, TestModel>,
                dataIn              = model,
                execStatus          = ActionExecStatus.Pending,
                rollbackActionClass = null,
                rollbackDataIn      = null,
                rollbackExecStatus  = ActionExecStatus.NoAction
            };

            Assert.AreEqual(new TestAction() as BusinessAction <TestModel, TestModel>, actionQueueEntry.actionClass);
            Assert.AreEqual(model, actionQueueEntry.dataIn);
            Assert.AreEqual(ActionExecStatus.Pending, actionQueueEntry.execStatus);
            Assert.Null(actionQueueEntry.rollbackActionClass);
            Assert.Null(actionQueueEntry.rollbackDataIn);
            Assert.AreEqual(ActionExecStatus.NoAction, actionQueueEntry.rollbackExecStatus);
        }
        public void ActionQueueRemoveMultipleEntries_Test()
        {
            var actionQueue = new ActionQueue <BusinessLogicEntity, BusinessLogicEntity>();
            var entry       = new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>();

            actionQueue.Add(entry);
            actionQueue.Remove(entry);
            Assert.AreEqual(0, actionQueue.Count);
        }
        public void ActionQueueCopyTo_Test()
        {
            var actionQueue = new ActionQueue <BusinessLogicEntity, BusinessLogicEntity>();

            actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>());
            actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>());
            actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>());
            actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>());
            actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>());
            ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>[] actionQueueArray = new
                                                                                             ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>[] { null, null, null, null, null, null, null };
            actionQueue.CopyTo(actionQueueArray, 1);
            Assert.AreEqual(5, actionQueueArray
                            .OfType <ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity> >()
                            .ToList()
                            .Where(c => c != null)
                            .Count());
        }
        public void ActionQueueIndexOf_Test()
        {
            var actionQueue = new ActionQueue <BusinessLogicEntity, BusinessLogicEntity>();

            actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>());
            var entry = new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>
            {
                actionClass = new TestAction(),
                dataIn      = new TestModel
                {
                    id = 100501,
                    simulate_action_error = false,
                    is_unrecoverable      = false
                },
                execStatus = ActionExecStatus.Pending
            };

            actionQueue.Add(entry);
            Assert.AreEqual(1, actionQueue.IndexOf(entry));
        }
        public void ActionQueueSetter_Test()
        {
            var actionQueue = new ActionQueue <BusinessLogicEntity, BusinessLogicEntity>();

            actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>());
            actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>());
            var entry = new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>
            {
                actionClass = new TestAction(),
                dataIn      = new TestModel
                {
                    id = 100501,
                    simulate_action_error = false,
                    is_unrecoverable      = false
                },
                execStatus = ActionExecStatus.Pending
            };

            actionQueue[1] = entry;
            Assert.AreEqual(2, actionQueue.Count());
            Assert.AreEqual(1, actionQueue
                            .Where(c => c.Equals(entry))
                            .Count());
        }