Ejemplo n.º 1
0
		public void UnsavedPart_IsAppendedLast_ToParent()
		{
			var page = CreatePageWithPart();

			var part2 = new StatefulPart();
			part2.Title = "New part 2";
			part2.Parent = page;
			part2.ZoneName = "TheZone";
			var context = new CommandContext(definitions.GetDefinition(page.GetContentType()), part2, Interfaces.Editing, CreatePrincipal("admin"), nullBinder, nullValidator);
			var command = CreateCommand(context);
			dispatcher.Execute(command, context);

			var pageVersion = versions.GetVersion(page, context.Content.VersionIndex);
			var partVersion = pageVersion.Children[0];
			var part2Version = pageVersion.Children[1];
			partVersion.SortOrder.ShouldBeLessThan(part2Version.SortOrder);
		}
Ejemplo n.º 2
0
		public void UnsavedPart_CanBeInserted_BeforeSortOrder()
		{
			var page = CreatePageWithPart();

			var part2 = new StatefulPart();
			part2.Title = "New part";
			part2.Name = "NewPart";
			part2.Parent = page;
			part2.ZoneName = "TheZone";
			var context = new CommandContext(definitions.GetDefinition(page.GetContentType()), part2, Interfaces.Editing, CreatePrincipal("admin"), nullBinder, nullValidator);
			context.Parameters["MoveBeforeSortOrder"] = "0";
			var command = CreateCommand(context);
			dispatcher.Execute(command, context);

			var pageVersion = versions.GetVersion(page, context.Content.VersionIndex);
			var partVersion = pageVersion.Children["ThePart"];
			var part2Version = pageVersion.Children["NewPart"];
			part2Version.SortOrder.ShouldBeLessThan(partVersion.SortOrder);
		}
Ejemplo n.º 3
0
		public void UnsavedPart_IsSavedOnNewPageVersion()
		{
			var page = new StatefulPage();
			page.Title = "The page";
			persister.Save(page);
			
			var part = new StatefulPart();
			part.Title = "New part";
			part.Parent = page;
			part.ZoneName = "TheZone";

			var context = new CommandContext(definitions.GetDefinition(page.GetContentType()), part, Interfaces.Editing, CreatePrincipal("admin"), nullBinder, nullValidator);

			var command = CreateCommand(context);
			dispatcher.Execute(command, context);

			var pageVersions = versions.GetVersionsOf(page);
			pageVersions.Count.ShouldBeGreaterThan(0);
			pageVersions.First().State.ShouldBe(ContentState.Draft);
			pageVersions.First().Children.Single().Title.ShouldBe("New part");
		}
Ejemplo n.º 4
0
		private CommandContext ExecuteSave(StatefulPage page, StatefulPart part)
		{
			var context = new CommandContext(definitions.GetDefinition(page.GetContentType()), part, Interfaces.Editing, CreatePrincipal("admin"), nullBinder, nullValidator);
			var command = CreateCommand(context);
			dispatcher.Execute(command, context);
			return context;
		}
Ejemplo n.º 5
0
		private StatefulPage CreatePageWithPart()
		{
			var page = new StatefulPage();
			page.Title = "The page";
			persister.Save(page);

			var part = new StatefulPart();
			part.Title = "The part";
			part.Name = "ThePart";
			part.Parent = page;
			part.ZoneName = "TheZone";
			persister.Save(part);
			return page;
		}