コード例 #1
0
        public static void Run()
        {
            try {
                Assert.AreEqual(
                    Sheep.Prototype.Name,
                    Sheep.Prototype.Clone().Name
                    );
            } catch (AssertFailedException e) {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine(string.Format(
                                  "Sheep prototype: {0}",
                                  Sheep.Prototype.Name
                                  ));

            Sheep dolly = Sheep.Prototype.Clone();

            dolly.Name = "Dolly";

            Console.WriteLine(string.Format(
                                  "Cloned new sheep: {0}",
                                  dolly.Name
                                  ));

            try {
                Assert.AreNotEqual(Sheep.Prototype, dolly);
            } catch (AssertFailedException e) {
                Console.WriteLine(e.Message);
            }
        }
コード例 #2
0
        public static void RunTest()
        {
            Sheep sally = new Sheep()
            {
                Name = "Sally"
            };
            Sheep clonedSheep = (Sheep)sally.Clone();

            Console.WriteLine(sally.Name);
            Console.WriteLine(clonedSheep.Name);
        }