Ejemplo n.º 1
0
        public void TestAllUpdate() {
            var so1 = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var so2 = new SimpleObject {ValueOne = 3, ValueTwo = 4};
            var so3 = new SimpleObject {ValueOne = 5, ValueTwo = 6};
            var so4 = new SimpleObject {ValueOne = 7, ValueTwo = 8};
            var ao = new AllObject {ValueOne = 9, ValueTwo = 10, ReferenceOne = so1};
            ao.CollectionOne.Add(so2);

            var clone = (AllObject) CopyUtils.CloneObjectTest(ao);

            clone.ValueTwo = 11;
            clone.ReferenceOne = so3;
            clone.CollectionOne.Add(so4);

            Assert.AreNotSame(ao, clone);
            Assert.AreSame(ao.GetType(), clone.GetType());
            Assert.AreEqual(ao.ValueOne, clone.ValueOne);
            Assert.AreNotEqual(ao.ValueTwo, clone.ValueTwo);
            Assert.AreNotSame(ao.ReferenceOne, clone.ReferenceOne);
            Assert.AreNotSame(ao.CollectionOne, clone.CollectionOne);
            Assert.AreNotEqual(ao.CollectionOne.Count(), clone.CollectionOne.Count());

            CopyUtils.UpdateFromClone(ao, clone);

            Assert.AreNotSame(ao, clone);
            Assert.AreSame(ao.GetType(), clone.GetType());
            Assert.AreNotSame(ao.CollectionOne, clone.CollectionOne);
            Assert.AreSame(ao.ReferenceOne, clone.ReferenceOne);
            Assert.AreEqual(ao.ValueOne, clone.ValueOne);
            Assert.AreEqual(ao.ValueTwo, clone.ValueTwo);
            Assert.AreEqual(ao.CollectionOne.Count(), clone.CollectionOne.Count());
            Assert.AreSame(ao.CollectionOne.First(), clone.CollectionOne.First());
            Assert.AreSame(ao.CollectionOne.ElementAt(1), clone.CollectionOne.ElementAt(1));
        }
Ejemplo n.º 2
0
        public void TestAllClone() {
            var so1 = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var so2 = new SimpleObject {ValueOne = 3, ValueTwo = 4};
            var ao = new AllObject {ValueOne = 5, ValueTwo = 6, ReferenceOne = so1};
            ao.CollectionOne.Add(so2);

            var clone = (AllObject) CopyUtils.CloneObjectTest(ao);
            Assert.AreNotSame(ao, clone);
            Assert.AreSame(ao.GetType(), clone.GetType());
            Assert.AreEqual(ao.ValueOne, clone.ValueOne);
            Assert.AreEqual(ao.ValueTwo, clone.ValueTwo);
            Assert.AreSame(ao.ReferenceOne, clone.ReferenceOne);
            Assert.AreNotSame(ao.CollectionOne, clone.CollectionOne);
            Assert.AreSame(ao.CollectionOne.First(), clone.CollectionOne.First());
        }
        public void TestAllUpdate()
        {
            var so1 = new SimpleObject {
                ValueOne = 1, ValueTwo = 2
            };
            var so2 = new SimpleObject {
                ValueOne = 3, ValueTwo = 4
            };
            var so3 = new SimpleObject {
                ValueOne = 5, ValueTwo = 6
            };
            var so4 = new SimpleObject {
                ValueOne = 7, ValueTwo = 8
            };
            var ao = new AllObject {
                ValueOne = 9, ValueTwo = 10, ReferenceOne = so1
            };

            ao.CollectionOne.Add(so2);

            var clone = (AllObject)CopyUtils.CloneObjectTest(ao);

            clone.ValueTwo     = 11;
            clone.ReferenceOne = so3;
            clone.CollectionOne.Add(so4);

            Assert.AreNotSame(ao, clone);
            Assert.AreSame(ao.GetType(), clone.GetType());
            Assert.AreEqual(ao.ValueOne, clone.ValueOne);
            Assert.AreNotEqual(ao.ValueTwo, clone.ValueTwo);
            Assert.AreNotSame(ao.ReferenceOne, clone.ReferenceOne);
            Assert.AreNotSame(ao.CollectionOne, clone.CollectionOne);
            Assert.AreNotEqual(ao.CollectionOne.Count, clone.CollectionOne.Count);

            CopyUtils.UpdateFromClone(ao, clone);

            Assert.AreNotSame(ao, clone);
            Assert.AreSame(ao.GetType(), clone.GetType());
            Assert.AreNotSame(ao.CollectionOne, clone.CollectionOne);
            Assert.AreSame(ao.ReferenceOne, clone.ReferenceOne);
            Assert.AreEqual(ao.ValueOne, clone.ValueOne);
            Assert.AreEqual(ao.ValueTwo, clone.ValueTwo);
            Assert.AreEqual(ao.CollectionOne.Count, clone.CollectionOne.Count);
            Assert.AreSame(ao.CollectionOne.First(), clone.CollectionOne.First());
            Assert.AreSame(ao.CollectionOne.ElementAt(1), clone.CollectionOne.ElementAt(1));
        }
        public void TestAllClone()
        {
            var so1 = new SimpleObject {
                ValueOne = 1, ValueTwo = 2
            };
            var so2 = new SimpleObject {
                ValueOne = 3, ValueTwo = 4
            };
            var ao = new AllObject {
                ValueOne = 5, ValueTwo = 6, ReferenceOne = so1
            };

            ao.CollectionOne.Add(so2);

            var clone = (AllObject)CopyUtils.CloneObjectTest(ao);

            Assert.AreNotSame(ao, clone);
            Assert.AreSame(ao.GetType(), clone.GetType());
            Assert.AreEqual(ao.ValueOne, clone.ValueOne);
            Assert.AreEqual(ao.ValueTwo, clone.ValueTwo);
            Assert.AreSame(ao.ReferenceOne, clone.ReferenceOne);
            Assert.AreNotSame(ao.CollectionOne, clone.CollectionOne);
            Assert.AreSame(ao.CollectionOne.First(), clone.CollectionOne.First());
        }
Ejemplo n.º 5
0
 public void dueDamage(AllObject target, int damage)
 {
     target.hpCurrent -= damage;
 }