예제 #1
0
        public void ConstructorTest()
        {
            // Arrange
            var mapCellsFactory = new Func <IAreaMapCellInternal>(() => new Mock <IAreaMapCellInternal>().Object);

            // Act
            var map = new AreaMap(1, mapCellsFactory, 5, 5);

            // Assert
            var cell = map.GetCell(2, 2);

            Assert.NotNull(cell);
        }
예제 #2
0
        public void GetCellValidTest(int width, int height, int checkX, int checkY)
        {
            // Arrange
            var mapCellsFactory = new Func <IAreaMapCellInternal>(() => new Mock <IAreaMapCellInternal>().Object);

            // Arrange
            var map = new AreaMap(1, mapCellsFactory, width, height);

            // Act
            var cell = map.GetCell(checkX, checkY);

            // Assert
            Assert.NotNull(cell);
        }
예제 #3
0
        public void GetCellInvalidTest(int width, int height, int checkX, int checkY, string errorArgument)
        {
            // Arrange
            var mapCellsFactory = new Func <IAreaMapCellInternal>(() => new Mock <IAreaMapCellInternal>().Object);

            var map = new AreaMap(1, mapCellsFactory, width, height);

            //Act
            var exception = Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                map.GetCell(checkX, checkY);
            });

            StringAssert.StartsWith($"Coordinate {errorArgument} value", exception.Message);
        }
예제 #4
0
        public void AddObjectTest()
        {
            // Arrange
            const int posX            = 1;
            const int posY            = 2;
            var       mapObject       = new Mock <IMapObject>();
            var       mapCellsFactory = new Func <IAreaMapCellInternal>(() => new AreaMapCell(new Mock <IEnvironment>().Object));
            var       map             = new AreaMap(1, mapCellsFactory, 5, 5);

            // Act
            map.AddObject(posX, posY, mapObject.Object);

            // Assert
            var cell    = (AreaMapCell)map.GetCell(posX, posY);
            var objects = cell.ObjectsCollection.ToArray();

            Assert.AreEqual(1, objects.Length);
            Assert.AreSame(mapObject.Object, objects[0]);
        }