Exemplo n.º 1
0
        public void CanFindAction()
        {
            var act  = new MockActOnFileInfo();
            var info = new FileInfoItem(new FileInfo("does.not.exist"));

            var getItems = new GetActionsForItem(new[] { act });

            var actionsForItem = getItems.ActionsForItem(ResultForItem(info));

            Assert.NotEmpty(actionsForItem);
            Assert.Contains(act, actionsForItem);
        }
Exemplo n.º 2
0
        public void CanNotFindActionWhichDoesntActOnItem()
        {
            var act     = new MockActOnFileInfo();
            var dontAct = new MockActOnFileInfoWithFilter(false);
            var info    = new FileInfoItem(new FileInfo("does.not.exist"));

            var getItems = new GetActionsForItem(new IActOnItem[] { act, dontAct });

            var actionsForItem = getItems.ActionsForItem(ResultForItem(info));

            Assert.NotEmpty(actionsForItem);
            Assert.Contains(act, actionsForItem);
            Assert.DoesNotContain(dontAct, actionsForItem);
        }
Exemplo n.º 3
0
        public void ExecuteCanActOnCommand()
        {
            var command  = new MockCommand();
            var action   = new ExecuteCommand();
            var getItems = new GetActionsForItem(new IActOnItem[] { action });

            var actionsForItem = getItems.ActionsForItem(ResultForItem(new CommandItem(command)));

            Assert.NotEmpty(actionsForItem);
            Assert.Contains(action, actionsForItem);

            action.ActOn(command);
            Assert.True(command.Acted);
        }
Exemplo n.º 4
0
        public void DefaultActionForItemAppearsFirst()
        {
            var act        = new MockActOnFileInfo();
            var defaultAct = new MockDefaultActOnFileInfo();
            var info       = new FileInfoItem(new FileInfo("does.not.exist"));

            var getItems = new GetActionsForItem(new IActOnItem[] { act, defaultAct },
                                                 new FakeFindDefaultActionForItemStrategy(defaultAct));

            var actionsForItem = getItems.ActionsForItem(ResultForItem(info));

            Assert.NotEmpty(actionsForItem);
            Assert.Contains(defaultAct, actionsForItem);
            Assert.Equal(defaultAct, actionsForItem.First());
        }
Exemplo n.º 5
0
        public void AttributeStrategyForDefaultActionForFileInfoShowsDoesNotFindAction()
        {
            var act        = new MockActOnFileInfo();
            var defaultAct = new MockDefaultActOnFileInfo();
            var run        = new Run();
            var info       = new FileInfoItem(new FileInfo("does.not.exist"));

            var actions  = new IActOnItem[] { act, defaultAct };
            var strategy = new GetDefaultActionBasedOnAttributeForType();

            strategy.Actions = actions;

            var getItems = new GetActionsForItem(actions, strategy);

            var actionsForItem = getItems.ActionsForItem(ResultForItem(info));

            Assert.NotEmpty(actionsForItem);
            Assert.DoesNotContain(run, actionsForItem);
        }