예제 #1
0
        public async Task GetRoomByIdAsync_WhenIdIsValid()
        {
            //arrange
            const int id            = 1;
            var       dummyResponse = new RoomResponse(new Room(new RoomType("Test type"), 1, 0, 0));

            _mockMazeRepo.Setup(rep => rep.GetRoomByIdAsync(id)).ReturnsAsync(dummyResponse);

            //act
            var result = await _mazeService.GetRoomByIdAsync(id);

            //assert
            Assert.IsNotNull(result.Room);
        }
예제 #2
0
        public async Task <IHttpActionResult> GetRoomByIdAsync(int id)
        {
            var result = await _mazeIntegrationService.GetRoomByIdAsync(id);

            if (!result.Success)
            {
                return(NotFound());
            }
            if (result.Room == null)
            {
                return(NotFound());
            }

            var roomResource = _mapper.Map <Room, RoomResource>(result.Room);

            return(Ok(roomResource));
        }