示例#1
0
        public void CopyFrom_Copies_Source_Properties()
        {
            ComplexChild  sourceChild = new ComplexChild();
            ComplexParent parent      = new ComplexParent();

            sourceChild.Parent       = parent;
            sourceChild.GroupId      = 317;
            sourceChild.ParentId     = 179;
            sourceChild.CreationTime = DateTime.Now;
            sourceChild.Note         = "Some pretty nice note.";

            ComplexChild target = new ComplexChild();

            target.CopyFrom(sourceChild);

            Assert.AreEqual(sourceChild.Parent, target.Parent);
            Assert.AreEqual(sourceChild.GroupId, target.GroupId);
            Assert.AreEqual(sourceChild.ParentId, target.ParentId);
            Assert.AreEqual(sourceChild.CreationTime, target.CreationTime);
            Assert.AreEqual(sourceChild.Note, target.Note);
        }
示例#2
0
        public void CopyFrom_Doesnot_Copy_Source_Id()
        {
            int targetId      = 797;
            int sourceChildId = 111;

            ComplexChild  sourceChild = new ComplexChild();
            ComplexParent parent      = new ComplexParent();

            sourceChild.Id           = sourceChildId;
            sourceChild.Parent       = parent;
            sourceChild.GroupId      = 317;
            sourceChild.ParentId     = 179;
            sourceChild.CreationTime = DateTime.Now;
            sourceChild.Note         = "Some pretty nice note.";

            ComplexChild target = new ComplexChild();

            target.Id = targetId;
            target.CopyFrom(sourceChild);

            Assert.AreNotEqual(sourceChild.Id, target.Id);
            Assert.AreEqual(targetId, target.Id);
        }