Beispiel #1
0
        public void GetChild_NoItemYeldsNull()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);

            Assert.IsNull(root.GetChild("item2"));
        }
Beispiel #2
0
        public void GetChild_NameIncludingDot()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item.1", root);

            Assert.AreEqual(item1, root.GetChild("item.1"));
        }
Beispiel #3
0
        public void AddTo_IsAppendedLast_EvenWhenSortOrder_MayIndicateOtherwise()
        {
            AnItem parent = new AnItem();
            AnItem child1 = new AnItem();

            child1.SortOrder = 4;
            AnItem child2 = new AnItem();

            child2.SortOrder = 3;
            AnItem child3 = new AnItem();

            child3.SortOrder = 2;
            AnItem child4 = new AnItem();

            child4.SortOrder = 1;

            child1.AddTo(parent);
            child2.AddTo(parent);
            child3.AddTo(parent);
            child4.AddTo(parent);

            Assert.AreEqual(child1, parent.Children[0]);
            Assert.AreEqual(child2, parent.Children[1]);
            Assert.AreEqual(child3, parent.Children[2]);
            Assert.AreEqual(child4, parent.Children[3]);
        }
Beispiel #4
0
        public void GetChild_WhenName_IncludesUnicodeCharacter()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "ännu en ångande ö", root);

            Assert.AreEqual(item1, root.GetChild("ännu en ångande ö"));
        }
Beispiel #5
0
        public void GetChild_NameIncluding_Slash_IsFound()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item.1", root);

            Assert.That(root.GetChild("item.1/"), Is.EqualTo(item1));
        }
Beispiel #6
0
		public void SettingReferenceTypeToDefailtRemovesDetail()
		{
			AnItem item = new AnItem();
			item.StringProperty = "hello";
			item.StringProperty = string.Empty;
			Assert.AreEqual(0, item.Details.Count);
		}
Beispiel #7
0
		public void SettingValueTypeToDefailtRemovesDetail()
		{
			AnItem item = new AnItem();
			item.IntProperty = 3;
			item.IntProperty = 0;
			Assert.AreEqual(0, item.Details.Count);
		}
Beispiel #8
0
        public void GetChild_WithEmptyStringDoesntThrowException()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);

            Assert.IsNull(root.GetChild(string.Empty));
        }
Beispiel #9
0
		public void NoVersionOf_InverseComparedToNull()
		{
			var item = new AnItem();
			var version = new AnItem { ID = 2 };

			(item.VersionOf != null).ShouldBe(true); // no longer supported
			(item.VersionOf != version).ShouldBe(true);
		}
Beispiel #10
0
        public void GetChildsChild()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(2, "item2", item1);

            Assert.AreEqual(item2, root.GetChild("item1/item2"));
        }
Beispiel #11
0
        public void SetDetail_WithBoolean_AddsDetail()
        {
            AnItem item = new AnItem();

            item.SetDetailAccessor("ADetail", false);

            Assert.That(item.Details["ADetail"], Is.Not.Null);
        }
Beispiel #12
0
        public void AddTo_IsAddedToChildren()
        {
            AnItem parent = new AnItem();
            AnItem child  = new AnItem();

            child.AddTo(parent);
            EnumerableAssert.Contains(parent.Children, child);
        }
Beispiel #13
0
        public void SetDetail_ToString_WithSameValueAsDefault_DoesntAddDetail()
        {
            AnItem item = new AnItem();

            item.SetDetailAccessor("ADetail", "howdy", "howdy");

            Assert.That(item.Details.ContainsKey("ADetail"), Is.False);
        }
Beispiel #14
0
        public void SetDetail_ToString_WithDefault_AddsDetail()
        {
            AnItem item = new AnItem();

            item.SetDetailAccessor("ADetail", "hello", "howdy");

            Assert.That(item.Details["ADetail"], Is.Not.Null);
        }
Beispiel #15
0
        public void AddTo_UpdatesParentRelation()
        {
            AnItem parent = new AnItem();
            AnItem child  = new AnItem();

            child.AddTo(parent);
            Assert.AreEqual(parent, child.Parent);
        }
Beispiel #16
0
        public void FindsGrandChild_WhenTrailingAspx()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(2, "item2", item1);

            Assert.That(root.GetChild("item1/item2/"), Is.EqualTo(item2));
        }
Beispiel #17
0
        public void GetChild_CanFindCurrentItem()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(3, "item2", item1);

            Assert.AreEqual(root.GetChild("/"), root);
        }
Beispiel #18
0
        public void GetChildsChildWithTrailContainingDots()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item.1", root);
            AnItem item2 = CreateOneItem <AnItem>(2, "item2", item1);

            Assert.AreEqual(item2, root.GetChild("item.1/item2"));
        }
Beispiel #19
0
        public void SetDetail_ToBoolean_WithSameValueAsDefault_DoesntAddDetail_True()
        {
            AnItem item = new AnItem();

            item.SetDetailAccessor("ADetail", true, true);

            Assert.That(item.Details.ContainsKey("ADetail"), Is.False);
        }
Beispiel #20
0
        public void SetDetail_ToString_WithDefault_AddsStringDetail_WithSameValue()
        {
            AnItem item = new AnItem();

            item.SetDetailAccessor("ADetail", "hello", "howdy");

            Assert.That(item.Details["ADetail"].Value, Is.EqualTo("hello"));
        }
Beispiel #21
0
        public void GetChild_FindGrandChild_WhenTrailingSlash()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(3, "item2", item1);

            Assert.AreEqual(root.GetChild("item1/item2/"), item2);
        }
Beispiel #22
0
        public void SetDetail_ToString_AddsStringDetail()
        {
            AnItem item = new AnItem();

            item.SetDetailAccessor("ADetail", "hello");

            Assert.That(item.Details["ADetail"].ValueType, Is.EqualTo(typeof(string)));
            Assert.That(item.Details["ADetail"].ValueTypeKey, Is.EqualTo(ContentDetail.TypeKeys.StringType));
        }
Beispiel #23
0
        public void GetChild_HolesInPathYeldsNull()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(3, "item2", item1);
            AnItem item3 = CreateOneItem <AnItem>(4, "item3", item2);

            Assert.IsNull(root.GetChild("item1/itemX/item3"));
        }
Beispiel #24
0
		public void SettingReferenceTypeAddsDetail()
		{
			AnItem item = new AnItem();
			item.StringProperty = "hello";
			Assert.AreEqual(1, item.Details.Count);
			Assert.AreEqual("hello", item.StringProperty);
			Assert.AreEqual("hello", item.Details["StringProperty"].Value);
			Assert.AreEqual("hello", item["StringProperty"]);
		}
Beispiel #25
0
		public void OneVersionOf_InverseComparedToNull()
		{
			var item = new AnItem();
			var version = new AnItem { ID = 2 };
			item.VersionOf = version;

			(item.VersionOf != null).ShouldBe(true);
			(item.VersionOf != version).ShouldBe(false);
		}
Beispiel #26
0
		public void SettingValueType_AddsDetail()
		{
			AnItem item = new AnItem();
			item.IntProperty = 3;
			Assert.AreEqual(1, item.Details.Count);
			Assert.AreEqual(3, item.IntProperty);
			Assert.AreEqual(3, item.Details["IntProperty"].Value);
			Assert.AreEqual(3, item["IntProperty"]);
		}
Beispiel #27
0
        public void SetDetail_ToBoolean_AddsBooleanDetail()
        {
            AnItem item = new AnItem();

            item.SetDetailAccessor("ADetail", false);

            Assert.That(item.Details["ADetail"].ValueType, Is.EqualTo(typeof(bool)));
            Assert.That(item.Details["ADetail"].ValueTypeKey, Is.EqualTo(ContentDetail.TypeKeys.BoolType));
        }
Beispiel #28
0
        public void NoVersionOf_ComparedToNull()
        {
            var item    = new AnItem();
            var version = new AnItem {
                ID = 2
            };

            (item.VersionOf == null).ShouldBe(true);
            (item.VersionOf == version).ShouldBe(false);
        }
Beispiel #29
0
        public void AddsToChildrenWhenOnlyParentIsSet()
        {
            AnItem parent = new AnItem();
            AnItem child  = new AnItem();

            child.Parent = parent;

            child.AddTo(parent);
            EnumerableAssert.Contains(parent.Children, child);
        }
Beispiel #30
0
        public void GetChild_WithManyChildren()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(3, "item2", root);
            AnItem item3 = CreateOneItem <AnItem>(4, "item3", root);

            Assert.AreEqual(item1, root.GetChild("item1"));
            Assert.AreEqual(item2, root.GetChild("item2"));
            Assert.AreEqual(item3, root.GetChild("item3"));
        }