Esempio n. 1
0
        private ExternalItem Create(string family, string key, Url url, ExternalItem container)
        {
            string externalUrl = url.RemoveQuery("edit").ToString();
            var    item        = new ExternalItem {
                Title = "", Name = key, ZoneName = family, Parent = container
            };

            item["ExternalUrl"] = externalUrl;
            persister.Save(item);
            return(item);
        }
		public void ItemBecomeExpired_ByDateChange_ChangesStateToUnpublished()
		{
			var item = new ExternalItem { State = ContentState.Published, Published = DateTime.Now.AddSeconds(-10), Expires = DateTime.Now.AddSeconds(-5) };
			using (engine.SecurityManager.Disable())
			{
				engine.Persister.Save(item);
			}
			action.Execute();

			item.State.ShouldBe(ContentState.Unpublished);
		}
		public void ItemBecomePublished_ByDateChange_ChangesStateToPublished()
		{
			var item = new ExternalItem { State = ContentState.Waiting, Published = N2.Utility.CurrentTime().AddSeconds(-10) };
			using (engine.SecurityManager.Disable())
			{
				engine.Persister.Save(item);
			}

			action.Execute();

			item.State.ShouldBe(ContentState.Published);
		}
		public void ItemMarkedForFuturePublishing_IsPublished_WhenPublishingTimeIsReached()
		{
			var item = new ExternalItem { Title = "Original", State = ContentState.Published, Published = DateTime.Now.AddSeconds(-10) };
			using (engine.SecurityManager.Disable())
			{
				engine.Persister.Save(item);

				var version = versionManager.AddVersion(item, asPreviousVersion: false);
				version.Title = "ToBePublished";
				action.MarkForFuturePublishing(version, DateTime.Now.AddSeconds(-5));
				versionManager.UpdateVersion(version);
			}

			action.Execute();

			var published = engine.Persister.Get(item.ID);
			var allVersions = versionManager.GetVersionsOf(published);
			var unpublished = allVersions.Single(v => v.State == ContentState.Unpublished);

			allVersions.Count.ShouldBe(2);
			published.Title.ShouldBe("ToBePublished");
			unpublished.Title.ShouldBe("Original");
		}
		public void VersionToBePublished_IsNotStoredInVersionList()
		{
			using (engine.SecurityManager.Disable())
			{
				var item = new ExternalItem { Title = "Original", State = ContentState.Published, Published = DateTime.Now.AddSeconds(-10) };
				engine.Persister.Save(item);

				var version = new ExternalItem { Title = "ToBePublished", State = ContentState.Published, Published = DateTime.Now.AddSeconds(-10), VersionOf = item };
				action.MarkForFuturePublishing(version, DateTime.Now.AddSeconds(-5));
				engine.Persister.Save(version);
			}

			action.Execute();

			var all = engine.Persister.Repository.Find();
			all.Count().ShouldBe(2);
		}