Beispiel #1
0
        public void ReturnCreatedAtResult()
        {
            //arrange
            var blockNumbers = new List <int> {
                91, 92, 93, 94, 95
            };
            var battleShipBlocks = new BattleShipToBeCreatedRequest
            {
                BlockNumbers = blockNumbers
            };
            var expectedBattleShip = Helper.FakeBattleShipFactory(blockNumbers, 5);

            var moqBattleShipService = new Mock <IBattleShipService>();

            moqBattleShipService
            .Setup(br => br.SaveBattleShip(It.IsAny <int>(), It.IsAny <List <BattleShipBlock> >()))
            .Returns(expectedBattleShip);

            var fakeBattleShipService = moqBattleShipService.Object;
            var fakeBattleShipRepo    = new Mock <IBattleShipRepo>().Object;
            var fakeBlockRepo         = new Mock <IBlockRepo>().Object;
            //sut
            var sut = new BattleShipController(
                fakeBoardRepo, fakeBattleShipRepo,
                fakeBlockRepo, fakeBattleShipService, fakeLogger);

            //act
            var response = sut.ApiBattleShipPost(Helper.FAKE_BOARD_ID, battleShipBlocks);

            //assert
            Assert.AreEqual((int)HttpStatusCode.Created, response.StatusCode);
        }