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(); }
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); }
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, }); }
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(); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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, }); }
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); }
public void RuntimeIdIsCreatedEveryTime() { var otherAction = new RealAction(); this.action.RuntimeId.Should().NotBe(otherAction.RuntimeId); }
public void Setup() { this.SetupItemTest(); this.action = new RealAction(); }