public void ItReturnsAllTheGameDefinitionsForTheGivenGamingGroup()
        {
            const int GAMING_GROUP_ID = 1;

            var expectedResults = new List <GameDefinitionSummary>
            {
                new GameDefinitionSummary
                {
                    Id     = 2,
                    Name   = "some game definition name",
                    Active = false,
                    BoardGameGeekGameDefinitionId = 3
                }
            };

            _autoMocker.Get <IGameDefinitionRetriever>().Expect(mock => mock.GetAllGameDefinitions(GAMING_GROUP_ID)).Return(expectedResults);

            var actualResults = _autoMocker.ClassUnderTest.GetGameDefinitions(GAMING_GROUP_ID);

            var actualData = AssertThatApiAction.ReturnsThisTypeWithThisStatusCode <GameDefinitionsSearchResultsMessage>(actualResults, HttpStatusCode.OK);
            var firstActualGameDefinitionSearchResultMessage = actualData.GameDefinitions[0];

            Assert.That(firstActualGameDefinitionSearchResultMessage.GameDefinitionId, Is.EqualTo(expectedResults[0].Id));
            Assert.That(firstActualGameDefinitionSearchResultMessage.GameDefinitionName, Is.EqualTo(expectedResults[0].Name));
            Assert.That(firstActualGameDefinitionSearchResultMessage.Active, Is.EqualTo(expectedResults[0].Active));
            Assert.That(firstActualGameDefinitionSearchResultMessage.BoardGameGeekGameDefinitionId, Is.EqualTo(expectedResults[0].BoardGameGeekGameDefinitionId));
            Assert.That(firstActualGameDefinitionSearchResultMessage.NemeStatsUrl,
                        Is.EqualTo(AbsoluteUrlBuilder.GetGameDefinitionUrl(firstActualGameDefinitionSearchResultMessage.GameDefinitionId)));
        }
Beispiel #2
0
        public void ItReturnsANewlyCreatedGameDefinitionMessage()
        {
            var expectedUrl   = AbsoluteUrlBuilder.GetGameDefinitionUrl(_expectedGameDefinition.Id);
            var actualResults = _autoMocker.ClassUnderTest.SaveNewGameDefinition(new NewGameDefinitionMessage(), _expectedGamingGroupId);

            var actualData = AssertThatApiAction.ReturnsThisTypeWithThisStatusCode <NewlyCreatedGameDefinitionMessage>(actualResults, HttpStatusCode.OK);

            Assert.That(actualData.GameDefinitionId, Is.EqualTo(_expectedGameDefinition.Id));
            Assert.That(actualData.GamingGroupId, Is.EqualTo(_expectedGamingGroupId));
            Assert.That(actualData.NemeStatsUrl, Is.EqualTo(expectedUrl));
        }
Beispiel #3
0
        public virtual HttpResponseMessage GetGameDefinitions([FromUri] int gamingGroupId)
        {
            var results = _gameDefinitionRetriever.GetAllGameDefinitions(gamingGroupId);

            var gameDefinitionsSearchResultsMessage = new GameDefinitionsSearchResultsMessage
            {
                GameDefinitions = results.Select(result => new GameDefinitionSearchResultMessage
                {
                    Active = result.Active,
                    BoardGameGeekGameDefinitionId = result.BoardGameGeekGameDefinitionId,
                    GameDefinitionId   = result.Id,
                    GameDefinitionName = result.Name,
                    NemeStatsUrl       = AbsoluteUrlBuilder.GetGameDefinitionUrl(result.Id)
                }).ToList()
            };

            return(Request.CreateResponse(HttpStatusCode.OK, gameDefinitionsSearchResultsMessage));
        }
        public virtual HttpResponseMessage SaveNewGameDefinition([FromBody] NewGameDefinitionMessage newGameDefinitionMessage, [FromUri] int gamingGroupId)
        {
            var createGameDefinitionRequest = new CreateGameDefinitionRequest
            {
                BoardGameGeekGameDefinitionId = newGameDefinitionMessage.BoardGameGeekObjectId,
                Name          = newGameDefinitionMessage.GameDefinitionName,
                GamingGroupId = newGameDefinitionMessage.GamingGroupId
            };

            var newGameDefinition = _createGameDefinitionComponent.Execute(createGameDefinitionRequest, CurrentUser);

            var newlyCreatedGameDefinitionMessage = new NewlyCreatedGameDefinitionMessage
            {
                GameDefinitionId = newGameDefinition.Id,
                GamingGroupId    = newGameDefinition.GamingGroupId,
                NemeStatsUrl     = AbsoluteUrlBuilder.GetGameDefinitionUrl(newGameDefinition.Id)
            };

            return(Request.CreateResponse(HttpStatusCode.OK, newlyCreatedGameDefinitionMessage));
        }