public void CheckLicenseTagInTile(ResultSingleTile query)
        {
            var tiles = Scope.Resolve <ITilesService>().GetTiles(query);

            foreach (var tile in tiles)
            {
                Scope.Resolve <ISearchSection>().WaitForLoading().Search(tile.Title);

                var tutorials = Scope.Resolve <ITutorialNavigator>().WaitForLoading().GetAllTilesCache();

                var found = tutorials.SingleOrDefault(t => t.Title == tile.Title);

                if (found != null)
                {
                    if (tile.HasLicenseTag)
                    {
                        Logger.Info($"{tile.Title} has license key: {found.HasLicenseKey()}");
                        Assert.That(found.HasLicenseKey(), Is.True, $"{found.Title} does not have license key");
                    }
                }
                else
                {
                    Logger.Info($"{tile.Title} was not found on th tutorial navigator page");
                }
            }
        }
        public void CheckTileTime(ResultSingleTile query)
        {
            var timeConverter = Scope.Resolve <ITimeConverter>();
            var tiles         = Scope.Resolve <ITilesService>().GetTiles(query);

            foreach (var tile in tiles)
            {
                var tutorials = Scope.Resolve <ITutorialNavigator>().WaitForLoading().GetAllTilesCache();
                var found     = tutorials.SingleOrDefault(t => t.Title == tile.Title);

                if (found != null)
                {
                    var tileTime = timeConverter.GetTime(tile.Time);
                    Logger.Info($"Tile with title \"{found.Title}\" has time \"{found.Time}\" on the page, \"{tileTime}\" from API Query");
                    Assert.That(
                        found.Time,
                        Is.EqualTo(tileTime),
                        $"{found.Title} has wrong time. Should have {tileTime}");
                }
                else
                {
                    Logger.Info($"{tile.Title} was not found on the tutorial navigator page");
                }
            }

            if (tiles.Count == 0)
            {
                Assert.Fail("There are no tiles on the page");
            }
        }
        public TutorialNavigatorLegend GetPageLegend(ResultSingleTile tilesQuery)
        {
            TutorialNavigatorScope context = GetContext(tilesQuery);

            var legend = new TutorialNavigatorLegend
            {
                CountGroups    = context.GroupsCount,
                CountMissions  = context.MissionsCount,
                CountTutorials = context.TutorialsCount
            };

            return(legend);
        }
        public TutorialNavigatorScope GetContext(ResultSingleTile tilesQuery)
        {
            IRestResponse response = GetSerachTilesJSON(tilesQuery);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(JsonConvert.DeserializeObject <TutorialNavigatorScope>(response.Content));
            }
            else
            {
                throw new WebException($"{response.StatusCode}");
            }
        }
        private IRestResponse GetSerachTilesJSON(ResultSingleTile tilesQuery)
        {
            var jsonQuery = JsonConvert.SerializeObject(tilesQuery);
            var query     = WebUtility.UrlEncode(jsonQuery);

            query = string.Concat(resourseUrl, query);

            var client = new RestClient(_appConfiguration.ProdUrl);

            var request = new RestRequest(query, Method.GET);

            var response = client.Execute(request);

            return(response);
        }
        public IList <Tile> GetNewTiles(ResultSingleTile tilesQuery)
        {
            var context = GetContext(tilesQuery);

            return(context.Tiles.Where(t => t.CreationDate > context.TutorialsNewFrom).ToList());
        }
 public int GetTutorialsAmount(ResultSingleTile tilesQuery)
 {
     return(GetContext(tilesQuery).TutorialsCount);
 }
 public int GetGroupsAmount(ResultSingleTile tilesQuery)
 {
     return(GetContext(tilesQuery).GroupsCount);
 }
 public int GetMissionsAmount(ResultSingleTile tilesQuery)
 {
     return(GetContext(tilesQuery).MissionsCount);
 }
 public int GetAllTutorialTypesAmount(ResultSingleTile tilesQuery)
 {
     return(GetContext(tilesQuery).TotalTutorialCount);
 }
 public IList <Tile> GetTiles(ResultSingleTile tilesQuery)
 {
     return(GetContext(tilesQuery).Tiles);
 }