Ejemplo n.º 1
0
        public void Dog_Factory_Test()
        {
            ICovariantFactory <IAnimal> factory = new CovariantFactory <Dog>();
            var dog = factory.CreateInstance("Sharik", 2);

            (dog is Dog).Should().BeTrue();
            dog.GetType().Should().Be(typeof(Dog));
            dog.Name.Should().Be("Sharik");
            dog.Age.Should().Be(2);
        }
Ejemplo n.º 2
0
        public void Wolf_Factory_Test()
        {
            ICovariantFactory <Dog> factory = new CovariantFactory <Wolf>();
            var wolf = factory.CreateInstance("Bamboo", 5);

            (wolf is Wolf).Should().BeTrue();
            wolf.GetType().Should().Be(typeof(Wolf));
            wolf.Name.Should().Be("Bamboo");
            wolf.Age.Should().Be(5);
        }
Ejemplo n.º 3
0
        private static void Main()
        {
            ICovariantFactory <IAnimal> dogFactory = new CovariantFactory <Dog>();
            var dog = dogFactory.CreateInstance("Sharik", 2);

            dog.SayName();
            dog.SayAge();

            ICovariantFactory <Dog> wolfFactory = new CovariantFactory <Wolf>();
            var wolf = wolfFactory.CreateInstance("Bamboo", 5);

            wolf.SayName();
            wolf.SayAge();
        }