public void TestNegativePageNumberIsNotAllowed()
    {
      IPagingParameters paging = new MutablePagingParameters(-1, 5);
      var request = new ReadItemByPathParameters(this.sessionConfig, this.defaultSource, null, paging, "/sitecore/content");

      Assert.Throws<ArgumentException>(() => this.builderForPath.GetUrlForRequest(request));
    }
    public void TestPagingCanBeOmittedForPath()
    {
      IPagingParameters paging = null;
      var request = new ReadItemByPathParameters(this.sessionConfig, this.defaultSource, null, paging, "/root");

      string result = this.builderForPath.GetUrlForRequest(request);
      string expected = "http://tumba.yumba/-/item/v1%2froot";

      Assert.AreEqual(expected, result);
    }
    public void TestValidRequestWithPath()
    {
      IPagingParameters paging = new MutablePagingParameters(3, 5);
      var request = new ReadItemByPathParameters(this.sessionConfig, this.defaultSource, null, paging, "/sitecore/content");

      string result = this.builderForPath.GetUrlForRequest(request);
      string expected = "http://tumba.yumba/-/item/v1%2fsitecore%2fcontent?page=3&pageSize=5";

      Assert.AreEqual(expected, result);
    }
    public void TestValidRequestWithPathForShellSite()
    {
      IPagingParameters paging = new MutablePagingParameters(1, 10);
      var request = new ReadItemByPathParameters(this.sitecoreShellConfig, this.defaultSource, null, paging, "/x/y/z");

      string result = this.builderForPath.GetUrlForRequest(request);
      string expected = "http://trololo.net/-/item/v234%2fsitecore%2fshell%2fx%2fy%2fz?page=1&pageSize=10";

      Assert.AreEqual(expected, result);
    }
    public void TestReadItemPathRequestCopiesPagingOptions()
    {
      var defaultSource = new MutableItemSource("master", "en", 33);
      var sessionSettings = new MutableSessionConfig("localhost", "/sitecore/shell", "v100500");

      ScopeParameters scope = new ScopeParameters();
      scope.AddScope(ScopeType.Parent);
      scope.AddScope(ScopeType.Self);

      string[] fields = { "Ukraine", "is", "Europe" };
      var queryParameters = new QueryParameters(PayloadType.Content, scope, fields);

      var pagingSettings = new MutablePagingParameters(1, 10);
      ReadItemByPathParameters request = new ReadItemByPathParameters(
        sessionSettings,
        defaultSource,
        queryParameters,
        pagingSettings,
        "/x/y/z");
      var otherRequest = request.DeepCopyGetItemByPathRequest();


      {
        pagingSettings.PageNumber = 20;
        pagingSettings.ItemsPerPageCount = 100500;


        Assert.AreEqual(10, otherRequest.PagingSettings.ItemsPerPageCount);
        Assert.AreEqual(1, otherRequest.PagingSettings.PageNumber);
      }
    }