public void TearDown() { this.itemSource = null; this.session.Dispose(); this.session = null; this.env = null; this.mediaSettings = null; }
public void Setup() { TestEnvironment env = TestEnvironment.DefaultTestEnvironment(); this.env = env; this.mediaSettings = new MediaLibrarySettings( "/sitecore/media library", "ashx", "~/media/"); var connection = new SessionConfig(this.env.InstanceUrl); var defaultSource = LegacyConstants.DefaultSource(); this.session = new ScTestApiSession(connection, env.Users.Admin, this.mediaSettings, defaultSource); this.itemSource = new MutableItemSource("master", "en", 3872); }
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); }
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); } }
public void TestReadItemQueryRequestCopiesPagingOptions() { 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); ReadItemByQueryParameters request = new ReadItemByQueryParameters( sessionSettings, defaultSource, queryParameters, pagingSettings, "/x/y/z"); var otherRequest = request.DeepCopyGetItemByQueryRequest(); { pagingSettings.PageNumber = 20; pagingSettings.ItemsPerPageCount = 100500; Assert.AreEqual(10, otherRequest.PagingSettings.ItemsPerPageCount); Assert.AreEqual(1, otherRequest.PagingSettings.PageNumber); } }
public void TestReadItemByIdCopiesItemSource() { 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(); { defaultSource.SetDatabase("web"); defaultSource.SetLanguage("xyz"); defaultSource.SetVersion(9999); Assert.AreEqual("master", otherRequest.ItemSource.Database); Assert.AreEqual("en", otherRequest.ItemSource.Language); Assert.AreEqual(33, otherRequest.ItemSource.VersionNumber.Value); Assert.AreNotSame(request.SessionSettings, otherRequest.SessionSettings); Assert.AreNotSame(request.ItemSource, otherRequest.ItemSource); Assert.AreNotSame(request.QueryParameters, otherRequest.QueryParameters); } }