コード例 #1
0
        public void CallActOnActionWithNoReturnValueReturnsProperObject()
        {
            var act  = new MockActOnFileInfo();
            var info = new FileInfoItem(new FileInfo("does.not.exist"));

            var result = act.ActOn((IItem)info);

            Assert.Equal(NoReturnValue.Object, result);
        }
コード例 #2
0
        public void CanCallAct()
        {
            var act  = new MockActOnFileInfo();
            var info = new FileInfoItem(new FileInfo("does.not.exist"));

            act.ActOn((IItem)info);
            Assert.True(act.Acted);
            Assert.Equal(act.Info, info.TypedItem);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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());
        }
コード例 #6
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);
        }