Ejemplo n.º 1
0
        public static void MutatingMethods_MutationsAffectOriginal()
        {
            MutatingStruct?ms = new MutatingStruct()
            {
                Value = 1
            };

            for (int i = 1; i <= 2; i++)
            {
                Assert.Equal(i.ToString(), ms.Value.ToString());
                Assert.Equal(i, ms.Value.Value);

                Assert.Equal(i.ToString(), ms.ToString());
                Assert.Equal(i + 1, ms.Value.Value);
            }

            for (int i = 3; i <= 4; i++)
            {
                Assert.Equal(i, ms.Value.GetHashCode());
                Assert.Equal(i, ms.Value.Value);

                Assert.Equal(i, ms.GetHashCode());
                Assert.Equal(i + 1, ms.Value.Value);
            }

            for (int i = 5; i <= 6; i++)
            {
                ms.Value.Equals(new object());
                Assert.Equal(i, ms.Value.Value);

                ms.Equals(new object());
                Assert.Equal(i + 1, ms.Value.Value);
            }
        }
Ejemplo n.º 2
0
        public void EqualsImpl()
        {
            MutatingStruct?ms = new MutatingStruct()
            {
                Value = 1
            };

            ms.Equals(new object());
            Assert.AreEqual(ms.Value.Value, 2, "#1");
        }