Пример #1
0
        public void NotSee_WhenLineOfSight_IsOutsideMapBounds()
        {
            // Arrange
            var Matrix = new Map(1, 3).Matrix;

            var mockWall = new Mock <ITile>();
            var mockAir  = new Mock <ITile>();

            mockWall.SetupGet(w => w.BlocksSight).Returns(true);
            mockAir.SetupGet(w => w.BlocksSight).Returns(false);
            Matrix[0][0].Tile = mockAir.Object;
            Matrix[0][0].Tile = mockAir.Object;
            Matrix[0][2].Tile = mockAir.Object;

            var mockMap = new Mock <Map>();
            var map     = mockMap.Object;

            map.Matrix = Matrix;
            var unit = new MockUnit(Matrix[0][0], mockMap.Object);

            // these Coordinates could be mocked
            var lineOfSightOutOfBounds =
                new List <ICoordinates> {
                new Coordinates(0, 0), new Coordinates(0, 1), new Coordinates(0, 2), new Coordinates(0, 3)
            };

            // TODO: Refracto can see function to be independent of unit, pass 2 coordinates and a map rather than depending on the unit
            // Act
            Assert.IsFalse(unit.CanSee(lineOfSightOutOfBounds));
        }
Пример #2
0
        public void NotSeeWhen_LineOfSight_IsBroken()
        {
            // Arrange

            // TODO: do the matrix creaion here without relying on map constuctor

            // Altho it brakes the isolation map used because  its initialise method creates
            // AND MAPS!! postion x,y  leaving us only to fill them with tiles

            // Creates a map off 3 tiles and puts a wall in the middle

            var Matrix = new Map(1, 3).Matrix;

            var mockWall = new Mock <ITile>();
            var mockAir  = new Mock <ITile>();

            mockWall.SetupGet(w => w.BlocksSight).Returns(true);
            mockAir.SetupGet(w => w.BlocksSight).Returns(false);
            Matrix[0][1].Tile = mockWall.Object;
            Matrix[0][0].Tile = mockAir.Object;
            Matrix[0][2].Tile = mockAir.Object;

            var mockMap = new Mock <Map>();
            var map     = mockMap.Object;

            map.Matrix = Matrix;

            var unit = new MockUnit(Matrix[0][0], mockMap.Object);
            // These Coordinates could be mocked
            var lineOfSight =
                new List <ICoordinates> {
                new Coordinates(0, 0), new Coordinates(0, 1), new Coordinates(0, 2)
            };

            // TODO Refracto can see function to be independent of unit, pass 2 coordinates and a map rather than depending on the unit or added as utility method in Map

            // Act
            Assert.IsFalse(unit.CanSee(lineOfSight));
        }