Beispiel #1
0
        static void Main(string[] args)
        {
            //将原有的People改造为Animal
            AnimalAdapter animal = new AnimalAdapter();

            animal.Climb();

            Console.ReadKey();
        }
Beispiel #2
0
 private void _addButton_Click(object sender, EventArgs e)
 {
     for (int incre = 0; incre <= _animalsNumericUpDown.Value - 1; incre++)
     {
         string        guid   = Guid.NewGuid().ToString();
         AnimalAdapter animal = _zoo.AnimalTypes[_animalsComboBox.SelectedIndex].CreateInstance(guid);
         _animals.Add(animal);
     }
 }
Beispiel #3
0
        public void meter_definition_works()
        {
            var path = TestHelper.SolutionPath + @"\ZooSample\obj\Debug\ZooSample.dll";

            ZooAdapter sut = ZooAdapter.Load(path); AnimalAdapter bob = sut.AnimalTypes[0].CreateInstance("Bob");

            double meterDefinition = 0.001;

            Assert.That(sut.MeterDefinition, Is.EqualTo(meterDefinition));
        }
Beispiel #4
0
        public void create_zoo_and_animal()
        {
            var path = TestHelper.SolutionPath + @"\ZooSample\obj\Debug\ZooSample.dll";

            ZooAdapter sut = ZooAdapter.Load(path); AnimalAdapter bob = sut.AnimalTypes[0].CreateInstance("Bob");

            AnimalAdapter roger  = sut.AnimalTypes[0].CreateInstance("Roger");
            AnimalAdapter loic   = sut.AnimalTypes[1].CreateInstance("Loïc");
            AnimalAdapter suarez = sut.AnimalTypes[1].CreateInstance("Suarez");

            Assert.That(bob.Name, Is.EqualTo("Bob"));
            Assert.That(roger.Name, Is.EqualTo("Roger"));
            Assert.That(loic.Name, Is.EqualTo("Loïc"));
            Assert.That(suarez.Name, Is.EqualTo("Suarez"));
        }
Beispiel #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.SetContentView(Resource.Layout.animal_layout);

            string        anchor  = Intent.GetStringExtra("anchor");
            Animal        animal  = JsonConvert.DeserializeObject <Animal>(Intent.GetStringExtra("animal"));
            AnimalAdapter adapter = new AnimalAdapter(this, new List <Animal>()
            {
                animal
            });

            ListView.Adapter = adapter;

            Button backButton = this.FindViewById <Button>(Resource.Id.BackButton);

            backButton.Click += this.OnBackClick;
        }
Beispiel #6
0
        public void initial_position_works()
        {
            var path = TestHelper.SolutionPath + @"\ZooSample\obj\Debug\ZooSample.dll";

            ZooAdapter sut = ZooAdapter.Load(path);

            AnimalAdapter bob    = sut.AnimalTypes[0].CreateInstance("Bob");
            AnimalAdapter roger  = sut.AnimalTypes[0].CreateInstance("Roger");
            AnimalAdapter loic   = sut.AnimalTypes[1].CreateInstance("Loïc");
            AnimalAdapter suarez = sut.AnimalTypes[1].CreateInstance("Suarez");

            double initialPositionXY = 0;

            Assert.That(bob.X, Is.EqualTo(initialPositionXY));
            Assert.That(roger.X, Is.EqualTo(initialPositionXY));
            Assert.That(loic.X, Is.EqualTo(initialPositionXY));
            Assert.That(suarez.X, Is.EqualTo(initialPositionXY));
            Assert.That(bob.Y, Is.EqualTo(initialPositionXY));
            Assert.That(roger.Y, Is.EqualTo(initialPositionXY));
            Assert.That(loic.Y, Is.EqualTo(initialPositionXY));
            Assert.That(suarez.Y, Is.EqualTo(initialPositionXY));
        }
Beispiel #7
0
 public void  AddAnimal(AnimalAdapter animal)
 {
     _animals.Add(animal);
 }