public void ReturnsValidPlayerBoard() { // Arrange var playerId = 1; var defaultBoard = BattleshipUtilityTestHelpers.CreateDefaultBoard(); _mockBattleshipUtility.Setup(m => m.CreateDefaultBoard()).Returns(defaultBoard); var memoryCache = new MemoryCache(new MemoryCacheOptions()); var battleshipController = new BattleshipController(memoryCache, _mockBattleshipUtility.Object); // Act var subject = battleshipController.Get(); // Assert Assert.AreEqual(subject.PlayerId, playerId); Assert.IsNotNull(subject.PlayerBoard); }
public void ReturnsValidBattleship() { // Arrange var battleshipOptions = new BattleshipOptions { Alignment = BattleShip.Horizontal, Column = 1, PlayerId = 1, Row = 1, ShipSize = 4, OpponentId = 2 }; _mockBattleshipUtility.Setup( m => m.AddBattleship( It.IsAny <Cell[][]>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())) .Returns(new BattleshipUtilityResult("Battleship added", BattleshipResultType.Added)); var memoryCache = MockMemoryCacheService.GetMemoryCache(BattleshipUtilityTestHelpers.CreateDefaultBoard()); var battleshipController = new BattleshipController(memoryCache, _mockBattleshipUtility.Object); // Act var subject = battleshipController.Add(battleshipOptions); // Assert Assert.IsNotNull(subject); Assert.AreEqual(subject.Value.ResultType, BattleshipResultType.Added); }