示例#1
0
 public EntityParent()
 {
     EntityChild = new EntityChild();
 }
 public void EntityRefHasValueTest2()
 {
     EntityChild child = new EntityChild();
     child.Parent = null;
     Assert.IsTrue(child.ParentHasValue);
 }
 public void EntityRefHasValueTest1()
 {
     EntityChild child = new EntityChild();
     Assert.IsFalse(child.ParentHasValue);
 }
 public void EntityRefExceptionTest()
 {
     EntityChild child = new EntityChild();
     child.Parent = null;
     child.ParentID = Guid.NewGuid();
 }
        public void EntityRefTest()
        {
            EntityChild child = new EntityChild();
            EntityParent parent = new EntityParent();

            Assert.IsFalse(string.IsNullOrEmpty(child[EntityChild.ParentPropertyName]), "Assert #1");
            Assert.IsFalse(string.IsNullOrEmpty(child[EntityChild.ParentIDPropertyName]), "Assert #2");

            child.Parent = parent;
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.ParentPropertyName]), "Assert #3");
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.ParentIDPropertyName]), "Assert #4");

            parent.ID = Guid.NewGuid();
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.ParentPropertyName]), "Assert #5");
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.ParentIDPropertyName]), "Assert #6");

            child.Parent = null;
            Assert.IsFalse(string.IsNullOrEmpty(child[EntityChild.ParentPropertyName]), "Assert #9");
            Assert.IsFalse(string.IsNullOrEmpty(child[EntityChild.ParentIDPropertyName]), "Assert #10");

            child = new EntityChild
            {
                ParentID = Guid.NewGuid()
            };
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.ParentPropertyName]), "Assert #7");
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.ParentIDPropertyName]), "Assert #8");
        }
        public void NullableEntityRefTest()
        {
            EntityChild child = new EntityChild();
            EntityParent parent = new EntityParent();

            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.NullableParentPropertyName]), "Assert #1");
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.NullableParentIDPropertyName]), "Assert #2");

            child.NullableParent = parent;
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.NullableParentPropertyName]), "Assert #3");
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.NullableParentIDPropertyName]), "Assert #4");

            child.Parent = null;
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.NullableParentPropertyName]), "Assert #5");
            Assert.IsTrue(string.IsNullOrEmpty(child[EntityChild.NullableParentIDPropertyName]), "Assert #6");
        }