Inheritance: N2.ContentItem, IPage
Beispiel #1
0
        public void InsertRootNode()
        {
            Assert.IsNotNull(engine);
            Assert.IsNotNull(engine.Persister);

            Definitions.PersistableItem1 item = CreateRoot("root", "root item");
        }
Beispiel #2
0
 public virtual void CanCreateDatabaseSchema()
 {
     CreateDatabaseSchema();
     PersistableItem1 testItem = new PersistableItem1();
     engine.Persister.Save(testItem);
     Assert.AreEqual(1, testItem.ID);
 }
Beispiel #3
0
        public void CloneItem()
        {
            // TODO: moveme
            Definitions.PersistableItem1 root = CreateRoot("root", "root item");
            root.BoolProperty     = false;
            root.DateTimeProperty = new DateTime(1978, 12, 02);
            root.DoubleProperty   = 3.1412;
            root.IntProperty      = 42;
            root.LinkProperty     = root;
            root.ObjectProperty   = new string[] { "one", "two", "three" };
            root.StringProperty   = "dida";
            engine.Persister.Save(root);

            Definitions.PersistableItem1 clonedRoot = (Definitions.PersistableItem1)root.Clone(true);
            Assert.AreNotEqual(root.ID, clonedRoot.ID);

            engine.Persister.Save(clonedRoot);
            Assert.AreEqual(root.BoolProperty, clonedRoot.BoolProperty);
            Assert.AreEqual(root.DateTimeProperty, clonedRoot.DateTimeProperty);
            Assert.AreEqual(root.DoubleProperty, clonedRoot.DoubleProperty);
            Assert.AreEqual(root.IntProperty, clonedRoot.IntProperty);
            Assert.AreEqual(root.LinkProperty, clonedRoot.LinkProperty);
            Assert.AreEqual(root.ObjectProperty, clonedRoot.ObjectProperty);
            Assert.AreEqual(root.StringProperty, clonedRoot.StringProperty);
            Assert.AreEqual(root.Name, clonedRoot.Name);
            Assert.AreEqual(root.Title, clonedRoot.Title);
            Assert.AreNotEqual(root.ID, clonedRoot.ID);

            foreach (N2.Details.ContentDetail detail in root.Details)
            {
                Assert.IsNotNull(clonedRoot[detail.Name]);
                Assert.AreNotSame(detail, clonedRoot[detail.Name]);
            }
        }
Beispiel #4
0
		public override void SetUp()
		{
			base.SetUp();

			accessor = new LuceneAccesor(new ThreadContext(), new DatabaseSection());
			indexer = new LuceneIndexer(accessor, new TextExtractor(new IndexableDefinitionExtractor(definitions)));
			root = CreateOneItem<PersistableItem1>(1, "The Root Page", null);
			indexer.Clear();
		}
        protected Definitions.PersistableItem1 CreateAndSaveItem(string name, string title, ContentItem parent)
        {
            Definitions.PersistableItem1 item = CreateOneItem <Definitions.PersistableItem1>(0, "nada", parent);
            item.Title = title;
            item.Name  = name;
            engine.Persister.Save(item);

            return(item);
        }
Beispiel #6
0
		public void Save_WithChildren_ChildState()
		{
			var parent = new PersistableItem1();
			persister.Save(parent);

			var child = new PersistableItem1 { Parent = parent };
			persister.Save(child);

			parent.ChildState.ShouldBe(CollectionState.ContainsVisiblePublicPages);
		}
Beispiel #7
0
        public virtual void CanDropDatabaseSchema()
        {
            CreateDatabaseSchema();
            DropDatabaseSchema();

            PersistableItem1 testItem = new PersistableItem1();
            ExceptionAssert.Throws<Exception>(
                delegate
                    {
                        engine.Persister.Save(testItem);
                    });
        }
Beispiel #8
0
		public void Save_WithChildren_DoubleSave()
		{
			var parent = new PersistableItem1();
			persister.Save(parent);

			var child = new PersistableItem1 { Parent = parent };
			persister.Save(child);

			parent.Children.Count.ShouldBe(1);

			persister.Save(parent);

			parent.Children.Count.ShouldBe(1);
		}
Beispiel #9
0
		public override void SetUp()
		{
			base.SetUp();

			var definitions = TestSupport.SetupDefinitions(typeof(PersistableItem1), typeof(PersistableItem2), typeof(PersistablePart1));

			accessor = new LuceneAccesor(new ThreadContext(), new DatabaseSection());
			indexer = new LuceneIndexer(accessor, new TextExtractor(new IndexableDefinitionExtractor(definitions)));
			searcher = new LuceneSearcher(accessor, persister);
			worker = new AsyncWorker();
			asyncIndexer = new AsyncIndexer(indexer, persister, worker, Rhino.Mocks.MockRepository.GenerateStub<IErrorNotifier>(), new DatabaseSection());
			tracker = new ContentChangeTracker(asyncIndexer, persister, new N2.Plugin.ConnectionMonitor(), new DatabaseSection());

			accessor.LockTimeout = 1L;
			indexer.Clear();
			root = CreateOneItem<PersistableItem1>(1, "The Root Page", null);
		}
Beispiel #10
0
		public void Save_WithDescendants()
		{
			var parent = new PersistableItem1();
			persister.Save(parent);

			var child1 = new PersistableItem1 { Parent = parent };
			persister.Save(child1);

			var child1_1 = new PersistableItem1 { Parent = child1 };
			persister.Save(child1_1);

			var child2 = new PersistableItem1 { Parent = parent };
			persister.Save(child2);

			var child2_1 = new PersistableItem1 { Parent = child2 };
			persister.Save(child2_1);

			persister.Save(parent);

			Find.EnumerateChildren(parent).Count().ShouldBe(4);
		}
Beispiel #11
0
		private void Create(out PersistableItem1 item, out PersistableItem1 item2)
		{
			item = CreateOneItem<PersistableItem1>(1, "Another", null);
			item.Published = DateTime.Now.AddSeconds(-10);
			item.Created = DateTime.Now.AddSeconds(-10);
			item.Updated = DateTime.Now.AddSeconds(-10);
			item.Expires = DateTime.Now.AddSeconds(10);
			item.SavedBy = "admin";
			item.SortOrder = 0;
			item.State = ContentState.Draft;
			indexer.Update(item);

			item2 = CreateOneItem<PersistableItem1>(2, "Before", null);
			item2.Published = DateTime.Now;
			item2.Created = DateTime.Now;
			item2.Updated = DateTime.Now;
			item2.Expires = DateTime.Now.AddSeconds(20);
			item2.SavedBy = "bob";
			item2.SortOrder = 1;
			item2.State = ContentState.Published;
			indexer.Update(item2);
		}
Beispiel #12
0
		//[TestCase(10)]
		//[TestCase(100)]
		//[TestCase(1000)]
		//[TestCase(10000)]
		public void Save_ManyAssociations_InSession(int iterations)
		{
			for (int i = 0; i < iterations; i++)
			{
				var parent = new PersistableItem1();
				persister.Save(parent);

				var child1 = new PersistableItem1 { Parent = parent };
				child1["parent"] = parent;
				persister.Save(child1);

				var child1_1 = new PersistableItem1 { Parent = child1 };
				child1_1["parent"] = child1_1;
				persister.Save(child1_1);

				var child2 = new PersistableItem1 { Parent = parent };
				child2["sibling"] = child1;
				persister.Save(child2);

				var child2_1 = new PersistableItem1 { Parent = child2 };
				child2_1["cousin"] = child1_1;
				persister.Save(child2_1);

				child1["child"] = child1_1;
				child1["sibling"] = child2;
				persister.Save(child1);

				child1_1["cousin"] = child2_1;
				persister.Save(child1_1);

				child2["child"] = child2_1;
				persister.Save(child2);

				Find.EnumerateChildren(parent).Count().ShouldBe(4);
			}
		}
Beispiel #13
0
		public void MultipleSessions()
		{
			for (int i = 0; i < 1; i++)
			{
				var parent = new PersistableItem1();
				persister.Save(parent);

				persister.Dispose();
				parent = persister.Get<PersistableItem1>(parent.ID);

				var child1 = new PersistableItem1 { Parent = parent };
				child1["parent"] = parent;
				persister.Save(child1);

				var child1_1 = new PersistableItem1 { Parent = child1 };
				child1_1["parent"] = child1_1;
				persister.Save(child1_1);

				persister.Dispose();

				parent = persister.Get<PersistableItem1>(parent.ID);
				child1 = persister.Get<PersistableItem1>(child1.ID);
				child1_1 = persister.Get<PersistableItem1>(child1_1.ID);

				var child2 = new PersistableItem1 { Parent = parent };
				child2.ZoneName = "TheZone";
				child2["sibling"] = child1;
				persister.Save(child2);

				var child2_1 = new PersistableItem1 { Parent = child2 };
				child2_1.ZoneName = "TheZone";
				child2_1["cousin"] = child1_1;
				persister.Save(child2_1);

				persister.Dispose();

				parent = persister.Get<PersistableItem1>(parent.ID);
				child1 = persister.Get<PersistableItem1>(child1.ID);
				child1_1 = persister.Get<PersistableItem1>(child1_1.ID);
				child2 = persister.Get<PersistableItem1>(child2.ID);
				child2_1 = persister.Get<PersistableItem1>(child2_1.ID);

				child1["child"] = child1_1;
				child1["sibling"] = child2;
				persister.Save(child1);

				child1_1["cousin"] = child2_1;
				persister.Save(child1_1);

				child2["child"] = child2_1;
				persister.Save(child2);

				persister.Dispose();

				persister.Get(parent.ID).Children.FindPages().Count().ShouldBe(1);
				persister.Get(parent.ID).Children.FindParts().Count().ShouldBe(1);

				persister.Get(parent.ID).Children.Select(c => c.ID).Contains(child1.ID).ShouldBe(true);
				persister.Get(parent.ID).Children.Select(c => c.ID).Contains(child2.ID).ShouldBe(true);

				persister.Get(child1.ID)["child"].ShouldBe(persister.Get(child1_1.ID));
			}
		}
 protected Definitions.PersistableItem1 CreateRoot(string name, string title)
 {
     Definitions.PersistableItem1 item = CreateAndSaveItem(name, title, null);
     return(item);
 }
Beispiel #15
0
		private void CreateStartPageBelow(ContentItem root)
		{
			startPage = CreateOneItem<PersistableItem1>(0, "start page", root);
			startPage.ZoneName = "AZone";
			startPage.SortOrder = 34;
			startPage.Visible = true;
            startPage.State = ContentState.Published;
			startPage.IntProperty = 33;
			startPage.DateTimeProperty = new DateTime(2013, 04, 07);
			startPage.EnumProperty = AppDomainManagerInitializationOptions.RegisterWithHost;
			startPage["IntDetail"] = 45;
			startPage["DoubleDetail"] = 56.66;
			startPage["BoolDetail"] = true;
			startPage["DateDetail"] = new DateTime(2000, 01, 01);
			startPage["StringDetail"] = "actually another string";
			startPage["StringDetail2"] = "just a string";
			startPage["ObjectDetail"] = new string[] { "two", "three", "four" };
			startPage["ItemDetail"] = root;

			engine.Persister.Save(startPage);
		}
Beispiel #16
0
		private void CreateRootItem()
		{
			rootItem = CreateOneItem<PersistableItem1>(0, "root", null);
			rootItem.Created = new DateTime(2007, 06, 01);
			rootItem.Published = new DateTime(2007, 06, 02);
			rootItem.Expires = new DateTime(2017, 06, 02);
			rootItem.ZoneName = "ZaZone";
			rootItem.SortOrder = 12;
			rootItem.Visible = true;
            rootItem.State = ContentState.Published;
			rootItem["IntDetail"] = 32;
			rootItem["DoubleDetail"] = 32.22;
			rootItem["BoolDetail"] = true;
			rootItem["DateDetail"] = new DateTime(1998, 12, 31);
			rootItem["StringDetail"] = "a string in a version";
			rootItem["StringDetail2"] = "just a string";
			rootItem["ObjectDetail"] = new string[] { "zero", "one", "two" };

			engine.Persister.Save(rootItem);
		}
Beispiel #17
0
		public void Save_ChildState()
		{
			var item = new PersistableItem1();
			persister.Save(item);
			item.ChildState.ShouldBe(CollectionState.IsEmpty);
		}