예제 #1
0
        void test4_Bugged()
        {
            Reptile a = new Reptile();

            if (a.SampleMethod() == 1)
            {
                Contract.Assert(false);
            }
        }
예제 #2
0
        void test4_NoBugs()
        {
            Reptile a = new Reptile();

            if (a.SampleMethod() != 1)
            {
                Contract.Assert(false);
            }
        }
예제 #3
0
        public static int test1_Bugged()
        {
            // correct order of checks
            // fist check mammal
            // second check reptil
            // third abstract version animal

            Animal a = new Mammal();

            int old_oxy = a.oxygen;
            int oxy     = a.Breathe();

            if (a is Mammal)
            {
                Contract.Assert(oxy == old_oxy * 2);
            }
            else if (a is Reptile)
            {
                Contract.Assert(oxy == old_oxy + 1);
            }
            else
            {
                Contract.Assert(false);
            }

            a = new Dog();

            old_oxy = a.oxygen;
            oxy     = a.Breathe();

            if (a is Mammal)
            {
                Contract.Assert(oxy == old_oxy * 2);
            }
            else if (a is Reptile)
            {
                Contract.Assert(oxy == old_oxy + 1);
            }
            else
            {
                Contract.Assert(false);
            }

            a       = new Reptile();
            old_oxy = a.oxygen;
            oxy     = a.Breathe();

            if (a is Mammal)
            {
                Contract.Assert(oxy == old_oxy * 2);
            }
            else if (a is Reptile)
            {
                Contract.Assert(oxy == old_oxy + 1);
            }
            else
            {
                Contract.Assert(false);
            }

            Contract.Assert(false);

            return(oxy);
        }