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); }
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); }
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); }
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]); }