Esempio n. 1
0
        public void ActorPageTest()
        {
            var seriesTitle = "The Blacklist";
            var actorsCount = 7;
            var actorSpader = "James Spader";
            var actorMarno  = "Mozhan Marnò";
            var actorTawfiq = "Hisham Tawfiq";
            var actorBoone  = "Megan Boone";

            Assert.That(new AnyPage(driver)
                        .ClickShowsMenuLnk()
                        .WaitForPageLoaded()
                        .IsSeriesDisplayed(seriesTitle), Is.True, $"Не отображается сериал: {seriesTitle}");

            var castpage = new ShowsPage(driver)
                           .GoToSeriesPageByTitle(seriesTitle)
                           .ClickAddToFavorites()
                           .GoToCastPage()
                           .WaitForPageLoaded();

            Assert.That(() => castpage.GetActorsCount(), Is.EqualTo(actorsCount).After(5000, 1000), "Не совпало количество актёров");
            Assert.That(castpage.IsActorDisplayed(actorSpader), Is.True, $"Не отображается актер: {actorSpader}");
            Assert.That(castpage.IsActorDisplayed(actorMarno), Is.True, $"Не отображается актер: {actorMarno}");
            Assert.That(castpage.IsActorDisplayed(actorTawfiq), Is.True, $"Не отображается актер: {actorTawfiq}");

            castpage.GoToActorPage(actorBoone).WaitForPageLoaded();

            Assert.That(new ActorPage(driver)
                        .ClickMore()
                        .IsLessBtnDisplayed(), Is.True, "Не отображатеся кнопка Less");
        }
Esempio n. 2
0
        public void ValidateTabsTest()
        {
            NBCHeader headerPage = new NBCHeader(driver);
            ShowsPage showsPage  = headerPage
                                   .ClickShowsTab()
                                   .ClickCurrentTab()
                                   .ClickUpcomingTab()
                                   .ClickThrowbackTab()
                                   .ClickAllTab();

            Assert.That(showsPage.IsShowBlockByNameExist(serialName), Is.True, $"Сериала с именем {serialName} нет");

            showsPage.ClickOnShowBlockByName(serialName);
        }
Esempio n. 3
0
        public void HT6Test()
        {
            var expectedActorsCount = 7;
            var JamesSpader         = "James Spader";
            var Mozhan = "Mozhan Marnò";
            var Hisham = "Hisham Tawfiq ";
            var Megan  = "Megan Boone";

            Allure.WrapInStep(() =>
            {
                NavigateToNBCSite();
            }, "Step1: Navigate To NBC Site");

            Allure.WrapInStep(() =>
            {
                var nbcShows = new NBCHeader(driver).ClickShows();
                Assert.That(nbcShows.IsShowBlockByNameExist(nbcSerialName),
                            Is.True, $"Сериала с именем {nbcSerialName} нет");
            }, "Step2: Check if the series exists");

            Allure.WrapInStep(() =>
            {
                var serialPage = new ShowsPage(driver)
                                 .ClickOnShowBlockByName(nbcSerialName)
                                 .ClickAddToFavorite()
                                 .ClosePopUpIfPresent()
                                 .ClickCast();
                Assert.Multiple(() =>
                {
                    Assert.That(() => serialPage.GetActorsCount(), Is.EqualTo(expectedActorsCount).After(30 * 1000, 1 * 1000), "Actors count is not as expected");
                    Assert.That(serialPage.IsActorPresent(JamesSpader), Is.True, $"Actor {JamesSpader} is not present");
                    Assert.That(serialPage.IsActorPresent(Mozhan), Is.True, $"Actor {Mozhan} is not present");
                    Assert.That(serialPage.IsActorPresent(Hisham), Is.True, $"Actor {Hisham} is not present");
                });
            }, "Step3: Check number of actors and name of actors in Cast tab");

            Allure.WrapInStep(() =>
            {
                new SerialPage(driver).ClickOnActor(Megan).ClickMoreButton();
            }, "Step4: Click on More button");

            Allure.WrapInStep(() =>
            {
                Assert.That(new SerialPage(driver).IsLessButtonDisplayed(), Is.True, "Button Less is not present");
            }, "Step5: Check if the Less button exists");
        }
Esempio n. 4
0
        public static async Task Run(
            [OrchestrationTrigger] DurableOrchestrationContext orchestrationContext,
            ILogger logger)
        {
            logger.LogInformation("{0} function processed a request.", nameof(InitialLoadingOrchestratorFunction));

            int pageNumber = 1;

            while (true)
            {
                logger.LogInformation("Processing {0} page", pageNumber);

                ShowsPage page = await orchestrationContext.CallActivityAsync <ShowsPage>(nameof(GetShowsPageFunction), pageNumber);

                if (page.IsLastPage)
                {
                    break;
                }

                IEnumerable <Task <CastInfo> > castInfosTasks = page.Shows.Select(
                    show => orchestrationContext.CallActivityAsync <CastInfo>(nameof(GetShowCastFunction), show.Id));

                var castInfos = await Task.WhenAll(castInfosTasks);

                var showsWithCast = new List <ShowWithCast>(page.Shows.Count);

                foreach (var castInfo in castInfos)
                {
                    var showToEnrich = page.Shows.First(show => show.Id == castInfo.ShowId);
                    showsWithCast.Add(
                        new ShowWithCast
                    {
                        Id      = showToEnrich.Id,
                        Name    = showToEnrich.Name,
                        Updated = showToEnrich.Updated,
                        Cast    = castInfo.Cast
                    });
                }

                await orchestrationContext.CallActivityAsync(nameof(InsertShowsFunction), showsWithCast);

                pageNumber++;
            }
        }
Esempio n. 5
0
        public async Task <IActionResult> List([FromQuery] PagingParameters parameters)
        {
            this.pageParametersValidator.EnsureValid(parameters);

            ShowsPage showsPage = await this.showsService.ListShowsAsync(parameters.PageNumber, parameters.PageSize);

            var showsDto = this.mapper.Map <ShowsDto>(showsPage);

            var actionInfo = new ActionInfo
            {
                UrlHelper  = this.urlHelper,
                RouteName  = nameof(this.List),
                HttpMethod = HttpMethod.Get.Method
            };

            showsDto.GenerateLinks(this.pageStringResources, actionInfo);

            return(this.Ok(showsDto));
        }
Esempio n. 6
0
        public async Task <ShowsPage> ListShowsAsync(int pageNumber, int pageSize)
        {
            if (pageNumber <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(pageNumber));
            }

            if (pageSize <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(pageSize));
            }

            var pageTask = this.showRepository.GetPageAsync(
                pageNumber,
                pageSize,
                show => new ShowDal
            {
                Id   = show.Id,
                Name = show.Name,
                Cast = show.Cast.OrderByDescending(actor => actor.DateOfBirth)
            });

            var countTask = this.showRepository.GetTotalCountAsync();

            int count = await countTask;
            IEnumerable <ShowDal> dalPage = await pageTask;

            var page = this.mapper.Map <ICollection <Show> >(dalPage);

            var showsPage = new ShowsPage
            {
                Count      = page.Count,
                PageNumber = pageNumber,
                PageSize   = pageSize,
                TotalPages = (int)Math.Ceiling((double)count / pageSize),
                TotalShows = count,
                Shows      = page
            };

            return(showsPage);
        }
Esempio n. 7
0
        public async Task <bool> ProcessPage(long pageId)
        {
            var client = _httpClientFactory.Service;

            var pageUrl  = _showsApiUrl.Replace(Constants.PageIdToken, pageId.ToString());
            var response = await client.Get(pageUrl);

            if (response.IsEnd)
            {
                return(false);
            }

            if (response.IsOk)
            {
                var shows = _jsonConverterFactory.Service.DeserializeObject <List <ShowCastModel> >(response.ResponseContent);
                foreach (var show in shows)
                {
                    var castUrl      = _showCastApiUrl.Replace(Constants.ShowIdToken, show.id);
                    var castResponse = await client.Get(castUrl);

                    if (castResponse.IsOk)
                    {
                        show.sourceCast = _jsonConverterFactory.Service.DeserializeObject <List <ShowCastModel.Person> >(castResponse.ResponseContent);
                    }
                }

                var showsJson = _jsonConverterFactory.Service.SerializeObject(shows);

                var showsPage = new ShowsPage {
                    Id = pageId, Json = showsJson
                };

                await _storageFactory.Service.AddOrUpdate(showsPage);
            }

            return(true);
        }