Пример #1
0
        public void PassingNullPassesNullToActionDataFactory()
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            var receivedObject = new object();

            action.ActionDataBuilder = x =>
            {
                receivedObject = x;

                return(null);
            };

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.GetAllActionData(null);

            receivedObject.Should().BeNull();
            action.PassedReceiver.Should().BeNull();
        }
Пример #2
0
        public void ExecutingActionChecksVisibilityWithRightExecutor()
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            object visibleReceivedObject = null;
            object enabledReceivedObject = null;

            action.SetVisibleCheck(x =>
            {
                visibleReceivedObject = x;

                return(true);
            });

            action.SetEnabledCheck(x =>
            {
                enabledReceivedObject = x;

                return(true);
            });

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            var passedObject = new object();

            item.ExecuteAction(passedObject, new IncomingItemActionData(action.RuntimeId));

            visibleReceivedObject.Should().NotBeNull().And.Be(passedObject);
            enabledReceivedObject.Should().NotBeNull().And.Be(passedObject);
        }
Пример #3
0
        public void ActionItemWillOnlyReturnVisibleItems()
        {
            var action      = new RealAction();
            var otherAction = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
                otherAction
            };

            var data      = new OutgoingItemActionData(action.RuntimeId);
            var otherData = new OutgoingItemActionData(otherAction.RuntimeId);

            action.ActionDataBuilder      = x => data;
            otherAction.ActionDataBuilder = x => otherData;

            otherAction.SetVisibleCheck((x) => false);

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.GetAllActionData(new object()).Should().Equal(new List <OutgoingItemActionData>
            {
                data,
            });
        }
Пример #4
0
        public void PassingNullAsExecutorToExecutePassesNullToAction()
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.ExecuteAction(null, new IncomingItemActionData(action.RuntimeId));

            action.PassedExecutor.Should().BeNull();
        }
Пример #5
0
        public void SettingEnabledToNullExecutesAction()
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            action.SetEnabledCheck(null);

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.ExecuteAction(null, new IncomingItemActionData(action.RuntimeId));

            action.ExecutedAmount.Should().Be(1);
        }
Пример #6
0
        public void AddingCorrectActionsRegistersItems()
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            var data = new IncomingItemActionData(action.RuntimeId);

            item.ExecuteAction(new object(), data);

            action.PassedActionData.Should().Be(data);
        }
Пример #7
0
        public void PassingExecutorToExecutePassesRightObject()
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            var passedObject = new object();

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.ExecuteAction(passedObject, new IncomingItemActionData(action.RuntimeId));

            action.PassedExecutor.Should().NotBeNull().And.Be(passedObject);
        }
Пример #8
0
        public void ActionItemReturnsAllCreatedData()
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            var data = new OutgoingItemActionData(action.RuntimeId);

            action.ActionDataBuilder = x => data;

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.GetAllActionData(new object()).Should().ContainSingle(x => x == data);
        }
Пример #9
0
        public void VisibleAndEnabledSetToSameValueWillOnlyTriggerIfBothTrue(bool enabled, bool shouldSucceed)
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            action.SetVisibleCheck(x => enabled);
            action.SetEnabledCheck(x => enabled);

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.ExecuteAction(null, new IncomingItemActionData(action.RuntimeId));

            action.ExecutedAmount.Should().Be(shouldSucceed ? 1 : 0);
        }
Пример #10
0
        public void EnabledStatusWillBeRespectedAndAppliesWhenVisibleIsTrue(bool enabled, bool shouldSucceed)
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            action.SetVisibleCheck(x => true);
            action.SetEnabledCheck(x => enabled);

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.ExecuteAction(null, new IncomingItemActionData(action.RuntimeId));

            action.ExecutedAmount.Should().Be(shouldSucceed ? 1 : 0);
        }
Пример #11
0
        public void SettingEnabledToNullRespectsVisibleStatus(bool visible, bool shouldSucceed)
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            action.SetVisibleCheck(x => visible);
            action.SetEnabledCheck(null);

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.ExecuteAction(null, new IncomingItemActionData(action.RuntimeId));

            action.ExecutedAmount.Should().Be(shouldSucceed ? 1 : 0);
        }
Пример #12
0
        public void DisablingItemKeepsActionDataInResult()
        {
            var action = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
            };

            var data = new OutgoingItemActionData(action.RuntimeId);

            action.ActionDataBuilder = x => data;

            action.SetVisibleCheck(x => true);
            action.SetEnabledCheck(x => false);

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.GetAllActionData(new object()).Should().ContainSingle(x => x == data);
        }
Пример #13
0
        public void ActionItemWillOnlyReturnVisibleItemsWithPositiveCheck()
        {
            var action      = new RealAction();
            var otherAction = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
                otherAction
            };

            var data      = new OutgoingItemActionData(action.RuntimeId);
            var otherData = new OutgoingItemActionData(otherAction.RuntimeId);

            action.ActionDataBuilder      = x => data;
            otherAction.ActionDataBuilder = x => otherData;

            otherAction.SetVisibleCheck(x => true);

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.GetAllActionData(new object()).Should().OnlyContain(x => x == data || x == otherData);
        }
Пример #14
0
        public void ActionItemReturnsNonNullCreatedMultipleData()
        {
            var action      = new RealAction();
            var otherAction = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
                otherAction
            };

            var data = new OutgoingItemActionData(action.RuntimeId);

            action.ActionDataBuilder      = x => data;
            otherAction.ActionDataBuilder = x => null;

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.GetAllActionData(new object()).Should().Equal(new List <OutgoingItemActionData>
            {
                data,
            });
        }
Пример #15
0
        public void PassingNullAsVisibleCheckCountsAsVisible()
        {
            var action      = new RealAction();
            var otherAction = new RealAction();

            RealActionItem.ActionGenerator = () => new List <IItemAction <OutgoingItemActionData, IncomingItemActionData> >
            {
                action,
                otherAction
            };

            var data      = new OutgoingItemActionData(action.RuntimeId);
            var otherData = new OutgoingItemActionData(otherAction.RuntimeId);

            action.ActionDataBuilder      = x => data;
            otherAction.ActionDataBuilder = x => otherData;

            otherAction.SetVisibleCheck(x => false);
            otherAction.SetVisibleCheck(null);

            var item = (RealActionItem)this.ItemFactory.CreateItem(ActionItemHandle, 1);

            item.GetAllActionData(new object()).Should().OnlyContain(x => x == data || x == otherData);
        }
Пример #16
0
        public void RuntimeIdIsCreatedEveryTime()
        {
            var otherAction = new RealAction();

            this.action.RuntimeId.Should().NotBe(otherAction.RuntimeId);
        }
Пример #17
0
        public void Setup()
        {
            this.SetupItemTest();

            this.action = new RealAction();
        }