Beispiel #1
0
        public override SessionConfig ShallowCopy()
        {
            var result = new MutableSessionConfig(
                "mock instance");

            // @adk : skipping validation
            result.SetInstanceUrl(this.InstanceUrl);

            return(result);
        }
        public override SessionConfig ShallowCopy()
        {
            var result = new MutableSessionConfig(
                "mock instance",
                "mock site",
                "v1");

            // @adk : skipping validation
            result.SetInstanceUrl(this.InstanceUrl);
            result.SetSite(this.Site);
            result.SetItemWebApiVersion(this.ItemWebApiVersion);

            return(result);
        }
    public override SessionConfig ShallowCopy()
    {
      var result = new MutableSessionConfig(
        "mock instance", 
        "mock site", 
        "v1");

      // @adk : skipping validation
      result.SetInstanceUrl(this.InstanceUrl);
      result.SetSite(this.Site);
      result.SetItemWebApiVersion(this.ItemWebApiVersion);

      return result;
    }
    public void TestSessionConfigCannotBeMutated()
    {
      var connection = new MutableSessionConfig("localhost");
      var anonymous = new MutableWebApiCredentialsPOD(null, null);

      var defaultSource = LegacyConstants.DefaultSource();

      var session = new ScApiSession(connection, anonymous, this.mediaSettings, defaultSource);

      Assert.AreEqual(defaultSource, session.DefaultSource);
      Assert.AreNotSame(defaultSource, session.DefaultSource);

      connection.SetInstanceUrl("sitecore.net");
      connection.SetSite("/sitecore/shell");
      connection.SetItemWebApiVersion("v100500");

      anonymous.Username = "******";
      anonymous.Password = "******";

      Assert.AreNotEqual(connection, session.Config);
      Assert.AreNotSame(connection, session.Config);
    }
    public void TestReadItemByIdCopiesSessionSettings()
    {
      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);

      IPagingParameters pagingSettings = null;
      ReadItemsByIdParameters request = new ReadItemsByIdParameters(
        sessionSettings,
        defaultSource,
        queryParameters,
        pagingSettings,
        "{aaaa-aa-bb}");
      var otherRequest = request.DeepCopyGetItemByIdRequest();

      {
        sessionSettings.SetInstanceUrl("paappaa");

        Assert.AreEqual("localhost", otherRequest.SessionSettings.InstanceUrl);
        Assert.AreNotSame(request.SessionSettings, otherRequest.SessionSettings);
        Assert.AreNotSame(request.ItemSource, otherRequest.ItemSource);
        Assert.AreNotSame(request.QueryParameters, otherRequest.QueryParameters);
      }
    }