public void AppendParameterSuccessEmptyQuery()
        {
            Uri url = new Uri(BaseUrl);
            const string key = "Test";
            const string value = "InsertedValue";

            string appendedUrl = url.AppendParameter(key, value);
           
            Assert.AreEqual($"{BaseUrl}?{key}={value}",appendedUrl);
        }
        public void AppendParameterEmptyKey()
        {
            string key = string.Empty;
            const string value = "InsertedValue";
            string extendedBaseUrl = $"{BaseUrl}";
            Uri url = new Uri(extendedBaseUrl);

            string appendedUrl = url.AppendParameter(key, value);

            Assert.AreEqual(url.AbsoluteUri, appendedUrl);
        }
        public void AppendParameterSuccessBaseUrlWithExistingKey()
        {
            const string key = "Test";
            const string value = "InsertedValue";
            string extendedBaseUrl = $"{BaseUrl}?{key}=PreValue";
            Uri url = new Uri(extendedBaseUrl);

            string appendedUrl = url.AppendParameter(key, value);

            Assert.AreEqual($"{BaseUrl}?{key}={value}", appendedUrl);
        }
        public void AppendParameterSuccessBaseUrlWithSubPageAndQuery()
        {
            string extendedBaseUrl = $"{BaseUrl}/SubPage?ExtendedParam=Value";
            Uri url = new Uri(extendedBaseUrl);
            const string key = "Test";
            const string value = "InsertedValue";

            string appendedUrl = url.AppendParameter(key, value);

            Assert.AreEqual($"{extendedBaseUrl}&{key}={value}", appendedUrl);
        }
 /// <summary>
 /// Generates a List of Paging Elements based on the parameter
 /// </summary>
 /// <returns>List of Paging elements, without previous and next</returns>
 public PagingModel GeneratePaging(Uri url, int pageNumber, int totalNumberOfElements)
 {
     int lastElement = (totalNumberOfElements / Settings.ElementsPerPage) + 1;
     return new PagingModel()
     {
         Elements = GeneratePagingElements(url, pageNumber, totalNumberOfElements),
         Last = new PageElement()
         {
             IsActive = false,
             Text = Labels.NextPagingElementText,
             Url = url.AppendParameter(Labels.PagingKey, lastElement.ToString())
         },
         First = new PageElement()
         {
             IsActive = false,
             Text = Labels.PreviousPagingElementText,
             Url = url.AppendParameter(Labels.PagingKey, "1")
         }
     };
 }
        /// <summary>
        /// Helper to generate a specific paging element with the given parameters
        /// </summary>
        /// <param name="url">url</param>
        /// <param name="pageNumber">page number</param>
        /// <param name="totalNumberOfElements">total number of elements</param>
        /// <returns>a filled paging element</returns>
        private static IEnumerable<PageElement> GeneratePagingElements(Uri url, int pageNumber, int totalNumberOfElements)
        {
            // Prepare the limits for the Paging elements
            int numberOfPagingElements = Settings.NumberOfPaingElements;
            int startIndex = pageNumber - numberOfPagingElements > 1 ? pageNumber - numberOfPagingElements : 1;
            int endIndex = pageNumber + numberOfPagingElements <= ((totalNumberOfElements / Settings.ElementsPerPage) + 1)
                ? pageNumber + numberOfPagingElements
                : (totalNumberOfElements / Settings.ElementsPerPage) + 1;

            // Use the limits for building the Paging
            for (int index = startIndex; index <= endIndex; index++)
            {
                string newUrl = url.AppendParameter(Labels.PagingKey, index.ToString());

                yield return new PageElement()
                {
                    Text = index.ToString(),
                    Url = newUrl,
                    IsActive = pageNumber == index
                };
            }
        }
        public void AppendParameterNullValue()
        {
            const string key = "Test";
            string value = null;
            string extendedBaseUrl = $"{BaseUrl}";
            Uri url = new Uri(extendedBaseUrl);

            string appendedUrl = url.AppendParameter(key, value);

            Assert.AreEqual(url.AbsoluteUri, appendedUrl);
        }