コード例 #1
0
    public void TestApiSessionConstructorRequiresConfig()
    {
      ItemSource defaultSource = LegacyConstants.DefaultSource();

      TestDelegate initSessionAction = () =>
      {
        ScApiSession result = new ScApiSession(null, this.credentials, this.mediaSettings, defaultSource);
        Debug.WriteLine( result );
      };

      Assert.Throws<ArgumentNullException>(initSessionAction);
    }
コード例 #2
0
    public void TestCredentialsCannotBeMutated()
    {
      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);

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

      Assert.AreNotEqual(anonymous, session.Credentials);
      Assert.AreNotSame(anonymous, session.Credentials);
    }
コード例 #3
0
    public void TestSessionDefaultSourceCannotBeMutated()
    {
      var connection = new SessionConfig("localhost");

      var defaultSource = new MutableItemSource("master", "en");
      var session = new ScApiSession(connection, null, this.mediaSettings, defaultSource);

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



      defaultSource.SetDatabase("web");
      defaultSource.SetLanguage("da");
      defaultSource.SetVersion(100500);
      Assert.AreNotEqual(defaultSource, session.DefaultSource);
      Assert.AreNotSame(defaultSource, session.DefaultSource);
    }
コード例 #4
0
    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);
    }
コード例 #5
0
 public void TestApiSessionConstructorDoesNotRequiresDefaultSource()
 {
   ScApiSession result = new ScApiSession(this.localhostConnection, this.credentials, this.mediaSettings, null);
   Assert.IsNotNull(result);
 }