コード例 #1
0
        public void OverrideEquals_DoesCheck_ValueEquality()
        {
            var fp1a = new FastPizza(1, 1);
            var fp1b = new FastPizza(1, 1);

            Assert.True(fp1a.Equals(fp1b));
            Assert.True(fp1a == fp1b);

            var fp2a = new FastPizza(2, 2);

            Assert.False(fp1a.Equals(fp1b));
            Assert.False(fp1a == fp2a);
        }
コード例 #2
0
        public void BaseEquals_DoesCheck_ValueEquality()
        {
            var fp1a = new Pizza(1, 1);
            var fp1b = new Pizza(1, 1);

            Assert.True(fp1a.Equals(fp1b));
            //Assert.True(fp1a == fp1b); //compiler error, there are no default == and != operators!

            var fp2a = new FastPizza(2, 2);

            Assert.False(fp1a.Equals(fp1b));
            //Assert.False(fp1a == fp2a); //compiler error, there are no default == and != operators!
        }