Example #1
0
        public void AsksForWithAbility_WhenQuestionNameIsWebBrowserQuestion_ShouldNotCallTakeScreenshotStrategy(
            [Frozen] Mock <IObserver <ScreenshotInfo> > observer,
            [Greedy] TakeScreenshot sut,
            IQuestion <object, object> question,
            IActor otherActor,
            object ability,
            object expected,
            object notExpected
            )
        {
            // arrange
            Mock.Get(question).Setup(q => q.AnsweredBy(otherActor, ability)).Returns(expected);
            Mock.Get(question).Setup(q => q.Name).Returns(TakeScreenshotOnErrorStrategy.GetWebBrowserQuestionName);
            Mock.Get(sut.Actor).Setup(a => a.AsksForWithAbility(It.IsAny <IQuestion <object, object> >())).Returns((IQuestion <object, object> a) => a.AnsweredBy(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) => notExpected);
            // act
            var actual = sut.AsksForWithAbility(question);

            // assert
            Assert.Equal(expected, actual);
        }
Example #2
0
        public void QuestionName_WithAbility_ShouldReturnCorrectValue(
            TakeScreenshot sut,
            IQuestion <object, object> question
            )
        {
            // arrange
            string actual = "";

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

            actual.Should().Be(expected);
        }