Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        public void CanGetReturnObjectFromCallAct()
        {
            var act  = new MockActOnFileInfoAndReturnString();
            var info = new FileInfoItem(new FileInfo("does.not.exist"));

            object returnedObject = act.ActOn((IItem)info);

            Assert.NotNull(returnedObject);
            var typedItem = returnedObject as ITypedItem <string>;

            Assert.NotNull(typedItem);
            Assert.Equal("does.not.exist", typedItem.Item);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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());
        }
Ejemplo n.º 7
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);
        }