Example #1
0
        public void ActionName_WithAbility_ShouldReturnCorrectValue(
            TakeScreenshot sut,
            IAction <object, object> action
            )
        {
            // arrange
            string actual = "";

            Mock.Get(sut.Actor).Setup(a => a.ExecuteWithAbility(It.IsAny <IAction <object, object> >()))
            .Callback((IAction <object, object> q) => actual = q.Name);
            // act
            sut.ExecuteWithAbility(action);
            // assert
            var expected = "[Take screenshot] " + action.Name;

            actual.Should().Be(expected);
        }
Example #2
0
        public void ExecuteWithAbility_CallingWhen_ShouldCallTakeScreenshotStrategy(
            [Frozen] Mock <IObserver <ScreenshotInfo> > observer,
            [Greedy] TakeScreenshot sut,
            IAction <object, object> action,
            IActor otherActor,
            object expected,
            object ability
            )
        {
            // arrange
            Mock.Get(action).Setup(q => q.ExecuteWhenAs(otherActor, ability)).Returns(expected);
            Mock.Get(sut.Actor).Setup(a => a.ExecuteWithAbility(It.IsAny <IAction <object, object> >())).Returns((IAction <object, object> a) => a.ExecuteWhenAs(otherActor, ability));
            Mock.Get(sut.TakeScreenshotStrategy).Setup(t => t.ExecuteTakeScreenshot(ability,
                                                                                    otherActor,
                                                                                    It.IsAny <Func <object> >(),
                                                                                    sut.NextScreenshotName,
                                                                                    observer.Object))
            .Returns <object, IActor, Func <object>, Func <string>, IObserver <ScreenshotInfo> >((a, b, execute, c, d) => execute());
            // act
            var actual = sut.ExecuteWithAbility(action);

            // assert
            Assert.Equal(expected, actual);
        }