public void TearDown()
    {
      this.builderForId = null;
      this.builderForPath = null;
      this.builderForQuery = null;

      this.sessionConfig = null;
      this.sitecoreShellConfig = null;
      this.defaultSource = null;
    }
    public void SetUp()
    {
      IRestServiceGrammar restGrammar = RestServiceGrammar.ItemWebApiV2Grammar();
      IWebApiUrlParameters webApiGrammar = WebApiUrlParameters.ItemWebApiV2UrlParameters();

      this.builder = new ItemByPathUrlBuilder(restGrammar, webApiGrammar);

      SessionConfigPOD mutableSession = new SessionConfigPOD();
      mutableSession.InstanceUrl = "http://mobiledev1ua1.dk.sitecore.net";
      mutableSession.ItemWebApiVersion = "v2";
      mutableSession.Site = "";
      this.sessionConfig = mutableSession;

      this.payload = new QueryParameters(PayloadType.Content, null, null);
    }
    public void SetUp()
    {
      IRestServiceGrammar restGrammar = RestServiceGrammar.ItemWebApiV2Grammar();
      IWebApiUrlParameters webApiGrammar = WebApiUrlParameters.ItemWebApiV2UrlParameters();

      this.builderForId = new ItemByIdUrlBuilder(restGrammar, webApiGrammar);
      this.builderForPath = new ItemByPathUrlBuilder(restGrammar, webApiGrammar);
      this.builderForQuery = new ItemByQueryUrlBuilder(restGrammar, webApiGrammar);

      this.defaultSource = new ItemSourcePOD(null, null, null);

      SessionConfigPOD mutableSessionConfig = new SessionConfigPOD();
      mutableSessionConfig.ItemWebApiVersion = "v1";
      mutableSessionConfig.InstanceUrl = "tumba.yumba";
      mutableSessionConfig.Site = null;
      this.sessionConfig = mutableSessionConfig;


      mutableSessionConfig = new SessionConfigPOD();
      mutableSessionConfig.ItemWebApiVersion = "v234";
      mutableSessionConfig.InstanceUrl = "trololo.net";
      mutableSessionConfig.Site = "/sitecore/shell";
      this.sitecoreShellConfig = mutableSessionConfig;
    }
 public void TearDown()
 {
     this.builder       = null;
     this.sessionConfig = null;
     this.payload       = null;
 }
 public GetItemsByPathTasks(ItemByPathUrlBuilder urlBuilder, HttpClient httpClient, ICredentialsHeadersCryptor credentialsHeadersCryptor)
     : base(httpClient, credentialsHeadersCryptor)
 {
     this.urlBuilder = urlBuilder;
 }
    public async Task<ScItemsResponse> ReadItemAsync(IReadItemsByPathRequest request, CancellationToken cancelToken = default(CancellationToken))
    {
      IReadItemsByPathRequest requestCopy = request.DeepCopyGetItemByPathRequest();

      using (ICredentialsHeadersCryptor cryptor = await this.GetCredentialsCryptorAsync(cancelToken))
      {
        IReadItemsByPathRequest autocompletedRequest = this.requestMerger.FillReadItemByPathGaps(requestCopy);

        var urlBuilder = new ItemByPathUrlBuilder(this.restGrammar, this.webApiGrammar);
        var taskFlow = new GetItemsByPathTasks(urlBuilder, this.httpClient, cryptor);

        return await RestApiCallFlow.LoadRequestFromNetworkFlow(autocompletedRequest, taskFlow, cancelToken);
      }
    }
 public GetItemsByPathTasks(ItemByPathUrlBuilder urlBuilder, HttpClient httpClient)
     : base(httpClient)
 {
     this.urlBuilder = urlBuilder;
 }
 public void TearDown()
 {
   this.builder = null;
   this.sessionConfig = null;
   this.payload = null;
 }
    public void TestDatabaseAndExplicitLanguageAndPayload()
    {
      var connection = new SessionConfig("localhost");

      var request = ItemWebApiRequestBuilder.ReadItemsRequestWithPath("/sitecore/content/oO")
        .Language("da")
        .Payload(PayloadType.Content)
        .Build();
      var requestMerger = new UserRequestMerger(connection, null);
      var mergedRequest = requestMerger.FillReadItemByPathGaps(request);

      var urlBuilder = new ItemByPathUrlBuilder(RestServiceGrammar.ItemWebApiV2Grammar(), WebApiUrlParameters.ItemWebApiV2UrlParameters());

      string result = urlBuilder.GetUrlForRequest(mergedRequest);
      string expected = "http://localhost/-/item/v1%2fsitecore%2fcontent%2foo?language=da&payload=content";

      Assert.AreEqual(expected, result);
    }
    public void TestOptionalSourceInSessionAndUserRequest()
    {
      var connection = new SessionConfig("localhost");

      var request = ItemWebApiRequestBuilder.ReadItemsRequestWithPath("/sitecore/content/oO").Build();
      var requestMerger = new UserRequestMerger(connection, null);
      var mergedRequest = requestMerger.FillReadItemByPathGaps(request);

      var urlBuilder = new ItemByPathUrlBuilder(RestServiceGrammar.ItemWebApiV2Grammar(), WebApiUrlParameters.ItemWebApiV2UrlParameters());

      string result = urlBuilder.GetUrlForRequest(mergedRequest);
      string expected = "http://localhost/-/item/v1%2fsitecore%2fcontent%2foo";

      Assert.AreEqual(expected, result);
    }