Esempio n. 1
0
        public async void WhenServiceResultIsBlank_FoundAtShouldBeNullOrEmpty()
        {
            //Arrange
            var query = Fixture.Build <GetStaticSearchResultQuery>()
                        .Create();
            var serviceResult = "";
            var serviceMock   = Fixture.Freeze <Mock <IStaticSearchService> >();

            serviceMock.Setup(f => f.Search(It.IsAny <string>()))
            .Returns(serviceResult);
            var handler = new GetStaticSearchResultQuery.Handler(new StaticSearch(serviceMock.Object));
            //Act
            var result = await handler.Handle(query, CancellationToken);

            //Assert
            result.FoundAt.ShouldBeNullOrEmpty();
        }
Esempio n. 2
0
        public async void WhenUrlOfInterestIsFoundInFirst50Results_IsSignificantShouldBeTrue()
        {
            //Arrange
            var urlOfInterest = @"https://www.infotrack.com.au";
            var query         = Fixture.Build <GetStaticSearchResultQuery>()
                                .With(p => p.UrlOfInterest, urlOfInterest)
                                .Create();
            var serviceResult = "<li class=#ads-fr# data-bg=#1#>" + urlOfInterest + "</li>";
            var serviceMock   = Fixture.Freeze <Mock <IStaticSearchService> >();

            serviceMock.Setup(f => f.Search(It.IsAny <string>()))
            .Returns(serviceResult);
            var handler = new GetStaticSearchResultQuery.Handler(new StaticSearch(serviceMock.Object));
            //Act
            var result = await handler.Handle(query, CancellationToken);

            //Assert
            result.IsSignificant.ShouldBe(true);
        }
Esempio n. 3
0
        public async void WhenServiceResultDoesNotContainUrlOfInterest_FoundAtShouldBeNullOrEmpty()
        {
            //Arrange
            var urlOfInterest = @"https://www.infotrack.com.au";
            var query         = Fixture.Build <GetStaticSearchResultQuery>()
                                .With(p => p.UrlOfInterest, urlOfInterest)
                                .Create();
            var serviceResult = "<li class=#ads-fr# data-bg=#1#>" + "abcd" + "</li>";
            var serviceMock   = Fixture.Freeze <Mock <IStaticSearchService> >();

            serviceMock.Setup(f => f.Search(It.IsAny <string>()))
            .Returns(serviceResult);
            var handler = new GetStaticSearchResultQuery.Handler(new StaticSearch(serviceMock.Object));
            //Act
            var result = await handler.Handle(query, CancellationToken);

            //Assert
            result.FoundAt.ShouldBeNullOrEmpty();
        }