コード例 #1
0
ファイル: AnimalFinderTest.cs プロジェクト: dim97/Savanna
        public void Setup()
        {
            _field           = new Mock <IField>();
            _distanceHandler = new Mock <IDistanceHandler>();
            _positionChecker = new Mock <IPositionChecker>();

            _position = new Point(0, 0);

            IAnimal[,] defaultAnimals = new IAnimal[2, 3];

            defaultAnimals[0, 0] = new Antilope();
            defaultAnimals[0, 1] = new Antilope();
            defaultAnimals[0, 2] = new Lion();
            defaultAnimals[1, 0] = null;
            defaultAnimals[1, 1] = null;
            defaultAnimals[1, 2] = new Lion();

            _field.Setup(f => f.Width).Returns(3);
            _field.Setup(f => f.Heigth).Returns(2);
            _field.Setup(f => f.Animals).Returns(defaultAnimals);

            List <Point> ExistingAnimals = new List <Point>();

            ExistingAnimals.Add(new Point(0, 0));
            ExistingAnimals.Add(new Point(1, 0));
            ExistingAnimals.Add(new Point(2, 1));
            ExistingAnimals.Add(new Point(2, 0));

            _positionChecker.Setup(f => f.CheckEmpty(It.IsIn <Point>(ExistingAnimals))).Returns(false);
            _positionChecker.Setup(f => f.CheckEmpty(It.IsNotIn <Point>(ExistingAnimals))).Returns(true);

            _systemUnderTest = new AnimalFinder(_field.Object, _positionChecker.Object, _distanceHandler.Object);
        }
コード例 #2
0
 public void CreateAnimal(IField field, AnimalLists animalLists, char animalBody)
 {
     if (animalBody == Settings.AntilopeBody)
     {
         var creature = new Antilope(_standardMovement, _validator, _preySpecial);
         _spawn.SetSpawnPoint(field, creature);
         animalLists.Prey.Add(creature);
     }
     else
     {
         var creature = new Lion(_standardMovement, _validator, _predSpecial);
         _spawn.SetSpawnPoint(field, creature);
         animalLists.Hunters.Add(creature);
     }
 }
コード例 #3
0
ファイル: FieldHandlerTest.cs プロジェクト: dim97/Savanna
        public void Setup()
        {
            GameField = new Mock <IField>();

            IAnimal[,] defaultAnimals = new IAnimal[2, 3];

            defaultAnimals[0, 0] = new Antilope();
            defaultAnimals[0, 1] = new Antilope();
            defaultAnimals[0, 2] = new Lion();
            defaultAnimals[1, 0] = null;
            defaultAnimals[1, 1] = null;
            defaultAnimals[1, 2] = new Lion();

            GameField.Setup(f => f.Width).Returns(3);
            GameField.Setup(f => f.Heigth).Returns(2);
            GameField.Setup(f => f.Animals).Returns(defaultAnimals);

            _systemUnderTest = new FieldHandler(GameField.Object);
        }