Exemplo n.º 1
0
        public static void Assert_StructsAreEqual(Struct s, Struct sCopy)
        {
            // values are same and then are not the same
            Assert.AreEqual(s.GetItem1(), sCopy.GetItem1());
            sCopy.IncrementItem1();
            Assert.AreNotEqual(s.GetItem1(), sCopy.GetItem1());
            sCopy.DecrementItem1();

            // Item23 and Item32 in struct should be the same instance (see constructor of Struct)
            Assert.AreSame(sCopy.Item23, sCopy.Item32);

            // reference field test
            if (s.Item23 != null)
            {
                SimpleClassTests.Assert_AreEqualButNotSame(s.Item23, sCopy.Item23);
            }

            // reference field test
            if (s.Item32 != null)
            {
                SimpleClassTests.Assert_AreEqualButNotSame(s.Item32, sCopy.Item32);
            }

            // readonly reference field test
            if (s.Item4 != null)
            {
                SimpleClassTests.Assert_AreEqualButNotSame(s.Item4, sCopy.Item4);
            }
        }