Esempio n. 1
0
        public void CorrectPoint_WhenAddPositiveVector()
        {
            var vector = new Vector(1, 3);

            var actual = point.AddVector(vector);

            Assert.AreEqual(new Point((int)(point.X + vector.X), (int)(point.Y + vector.Y)), actual);
        }
Esempio n. 2
0
        public void FishVelocityChanged_WhenFishHitsBounds()
        {
            fishPos = new Point(aquariumSize.Width - fishSize.Width - 1, aquariumSize.Height - fishSize.Height - 1);
            var newPos = fishPos.AddVector(fishVelocity);

            SetUpMocksForMovingFish(fishPos, newPos);
            aquarium.AddFish(mockFish.Object, mockFishDrawable.Object);

            aquarium.Iterate();

            mockFish.Verify(f => f.ChangeVelocity(), Times.Once);
        }
Esempio n. 3
0
        public void FoodPositionDoesNotChange_WhenOnBottom()
        {
            var startPos = new Point(0, aquarium.Size.Height - foodSize.Height - 1);
            var newPos   = startPos.AddVector(new Vector(0, foodWeight));

            SetUpMocksForMovingFood(startPos, newPos);
            aquarium.AddFood(mockFood.Object, mockFoodDrawable.Object);

            aquarium.Iterate();


            Assert.AreEqual(startPos, aquarium.Food.First(p => p.Key == mockFood.Object).Value.Position);
        }
Esempio n. 4
0
        public void FoodPositionChangesCorrectly_WhenIterate()
        {
            var startPos = new Point(0, 0);
            var expected = startPos.AddVector(new Vector(0, foodWeight));

            SetUpMocksForMovingFood(startPos, expected);
            aquarium.AddFood(mockFood.Object, mockFoodDrawable.Object);

            aquarium.Iterate();


            Assert.AreEqual(expected, aquarium.Food.First(p => p.Key == mockFood.Object).Value.Position);
        }
Esempio n. 5
0
        public void FishPositionChangesCorrectly_WhenIterate()
        {
            var startPos = new Point(0, 0);
            var expected = startPos.AddVector(fishVelocity);

            SetUpMocksForMovingFish(startPos, expected);
            aquarium.AddFish(mockFish.Object, mockFishDrawable.Object);

            aquarium.Iterate();


            Assert.AreEqual(expected, aquarium.Fishes.First(p => p.Key == mockFish.Object).Value.Position);
        }
    void simpleVector()
    {
        p.x = 3;
        p.y = 3;
        print(p.x);

        v.x = 2;
        v.y = 3;
        print(v.x);

        p2 = p.AddVector(v);

        print("X:" + p2.x + "Y:" + p2.y);
    }
Esempio n. 7
0
        public void FishStaysInBounds_WhenIsMovingOutOfBounds_BottomRight()
        {
            fishPos = new Point(aquariumSize.Width - fishSize.Width - 1, aquariumSize.Height - fishSize.Height - 1);
            var newPos = fishPos.AddVector(fishVelocity);

            SetUpMocksForMovingFish(fishPos, newPos);
            aquarium.AddFish(mockFish.Object, mockFishDrawable.Object);

            aquarium.Iterate();

            var actual = aquarium.Fishes.First().Value.Position;

            Assert.True(actual.X + fishSize.Width < aquariumSize.Width &&
                        actual.Y + fishSize.Height < aquariumSize.Height);
        }
Esempio n. 8
0
        public void FishStaysInBounds_WhenIsMovingOutOfBounds_UpLeft()
        {
            fishVelocity = new Vector(-2, -3);
            mockFish.Setup(f => f.Velocity).Returns(fishVelocity);
            fishPos = new Point(0, 0);
            var newPos = fishPos.AddVector(fishVelocity);

            SetUpMocksForMovingFish(fishPos, newPos);
            aquarium.AddFish(mockFish.Object, mockFishDrawable.Object);

            aquarium.Iterate();

            var actual = aquarium.Fishes.First().Value.Position;

            Assert.True(actual.X >= 0 && actual.Y >= 0);
        }
Esempio n. 9
0
        public void SetUp()
        {
            aquariumSize = new Size(800, 600);
            fishSize     = new Size(60, 20);
            fishPos      = new Point(0, 0);
            fishVelocity = new Vector(2, 3);

            foodWeight = 2;
            foodSize   = new Size(5, 5);

            aquarium = new Aquarium(aquariumSize, null);

            mockFish = new Mock <IFish>();
            mockFish.Setup(f => f.IsAlive).Returns(true);
            mockFish.Setup(f => f.Velocity).Returns(fishVelocity);


            mockFishDrawable = new Mock <IDrawable>();
            mockFishDrawable.Setup(f => f.Size).Returns(fishSize);
            mockFishDrawable.Setup(f => f.Position).Returns(fishPos);
            newMockFishDrawable = new Mock <IDrawable>();
            newMockFishDrawable.Setup(f => f.Size).Returns(fishSize);

            mockFoodDrawable = new Mock <IDrawable>();
            mockFoodDrawable.Setup(f => f.Size).Returns(foodSize);
            mockFoodDrawable.Setup(f => f.UpdatePosition(It.IsAny <Point>())).Returns(mockFoodDrawable.Object);
            newMockFoodDrawable = new Mock <IDrawable>();
            newMockFoodDrawable.Setup(f => f.Size).Returns(foodSize);
            newMockFoodDrawable.Setup(f => f.UpdatePosition(It.IsAny <Point>())).Returns(newMockFoodDrawable.Object);


            mockFood = new Mock <IFood>();
            mockFood.Setup(f => f.Weight).Returns(foodWeight);

            SetUpMocksForMovingFish(fishPos, fishPos.AddVector(fishVelocity));
        }
 /// <summary>
 /// See <see cref="IPointTransformationHelper.TranslatePoint"/>.
 /// </summary>
 public Point TranslatePoint(Vector2 offset, Point point)
 {
     return(point.AddVector(offset));
 }