Beispiel #1
0
        public void AsksFor_WhenQuestionNameIsWebBrowserQuestion_ShouldNotCallTakeScreenshotStrategy(
            [Frozen] Mock <IObserver <ScreenshotInfo> > observer,
            [Greedy] TakeScreenshot sut,
            IQuestion <object> question,
            IActor otherActor,
            object expected,
            object notExpected
            )
        {
            // arrange
            Mock.Get(question).Setup(q => q.AnsweredBy(otherActor)).Returns(expected);
            Mock.Get(question).Setup(q => q.Name).Returns(TakeScreenshotOnErrorStrategy.GetWebBrowserQuestionName);
            Mock.Get(sut.Actor).Setup(a => a.AsksFor(It.IsAny <IQuestion <object> >())).Returns((IQuestion <object> a) => a.AnsweredBy(otherActor));
            Mock.Get(sut.TakeScreenshotStrategy).Setup(t => t.ExecuteTakeScreenshot(Unit.Default,
                                                                                    otherActor,
                                                                                    It.IsAny <Func <object> >(),
                                                                                    sut.NextScreenshotName,
                                                                                    observer.Object))
            .Returns <Unit, IActor, Func <object>, Func <string>, IObserver <ScreenshotInfo> >((a, b, execute, c, d) => notExpected);
            // act
            var actual = sut.AsksFor(question);

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

            Mock.Get(sut.Actor).Setup(a => a.AsksFor(It.IsAny <IQuestion <object> >()))
            .Callback((IQuestion <object> q) => actual = q.Name);
            // act
            sut.AsksFor(question);
            // assert
            var expected = question.Name;

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