Exemplo n.º 1
0
        public void ItSavesTheNewGameDefinition()
        {
            var newGameDefinitionMessage = new NewGameDefinitionMessage
            {
                GameDefinitionName    = "some gameDefinitionName",
                BoardGameGeekObjectId = 1
            };

            autoMocker.ClassUnderTest.SaveNewGameDefinition(newGameDefinitionMessage, 0);

            autoMocker.Get <IGameDefinitionSaver>().AssertWasCalled(
                mock => mock.CreateGameDefinition(Arg <CreateGameDefinitionRequest> .Matches(gameDefinition => gameDefinition.Name == newGameDefinitionMessage.GameDefinitionName &&
                                                                                             gameDefinition.BoardGameGeekGameDefinitionId == newGameDefinitionMessage.BoardGameGeekObjectId),
                                                  Arg <ApplicationUser> .Is.Same(applicationUser)));
        }
Exemplo n.º 2
0
        public virtual HttpResponseMessage SaveNewGameDefinition([FromBody] NewGameDefinitionMessage newGameDefinitionMessage, [FromUri] int gamingGroupId)
        {
            var createGameDefinitionRequest = new CreateGameDefinitionRequest
            {
                BoardGameGeekGameDefinitionId = newGameDefinitionMessage.BoardGameGeekObjectId,
                Name = newGameDefinitionMessage.GameDefinitionName
            };

            var newGameDefinition = gameDefinitionSaver.CreateGameDefinition(createGameDefinitionRequest, CurrentUser);

            var newlyCreatedGameDefinitionMessage = new NewlyCreatedGameDefinitionMessage
            {
                GameDefinitionId = newGameDefinition.Id
            };

            return(Request.CreateResponse(HttpStatusCode.OK, newlyCreatedGameDefinitionMessage));
        }
        public void ItSavesTheNewGameDefinition()
        {
            var newGameDefinitionMessage = new NewGameDefinitionMessage
            {
                GameDefinitionName    = "some gameDefinitionName",
                BoardGameGeekObjectId = 1,
            };

            _autoMocker.ClassUnderTest.SaveNewGameDefinition(newGameDefinitionMessage, _expectedGamingGroupId);

            _autoMocker.Get <ICreateGameDefinitionComponent>().AssertWasCalled(
                mock => mock.Execute(Arg <CreateGameDefinitionRequest> .Matches(
                                         gameDefinition => gameDefinition.Name == newGameDefinitionMessage.GameDefinitionName &&
                                         gameDefinition.BoardGameGeekGameDefinitionId == newGameDefinitionMessage.BoardGameGeekObjectId &&
                                         gameDefinition.GamingGroupId == _expectedGamingGroupId),
                                     Arg <ApplicationUser> .Is.Same(_applicationUser)));
        }
        public void ItSavesTheNewGameDefinitionUsingTheGamingGroupIdOnTheRequestIfOneIsSpecified()
        {
            var newGameDefinitionMessage = new NewGameDefinitionMessage
            {
                GameDefinitionName    = "some gameDefinitionName",
                BoardGameGeekObjectId = 1,
                GamingGroupId         = _expectedGamingGroupId
            };
            int someGamingGroupIdThatWontGetUsed = -100;

            _autoMocker.ClassUnderTest.SaveNewGameDefinition(newGameDefinitionMessage, someGamingGroupIdThatWontGetUsed);

            _autoMocker.Get <IGameDefinitionSaver>().AssertWasCalled(
                mock => mock.CreateGameDefinition(Arg <CreateGameDefinitionRequest> .Matches(
                                                      gameDefinition => gameDefinition.Name == newGameDefinitionMessage.GameDefinitionName &&
                                                      gameDefinition.BoardGameGeekGameDefinitionId == newGameDefinitionMessage.BoardGameGeekObjectId &&
                                                      gameDefinition.GamingGroupId == newGameDefinitionMessage.GamingGroupId),
                                                  Arg <ApplicationUser> .Is.Same(_applicationUser)));
        }
        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));
        }
 public virtual HttpResponseMessage SaveNewGameDefinition([FromBody]NewGameDefinitionMessage newGameDefinitionMessage)
 {
     return SaveNewGameDefinition(newGameDefinitionMessage, CurrentUser.CurrentGamingGroupId);
 }
 public virtual HttpResponseMessage SaveNewGameDefinition([FromBody] NewGameDefinitionMessage newGameDefinitionMessage)
 {
     //--gamingGroupId is obsolete here and will be on the request or else used from the current user context -- so just pass "0"
     return(SaveNewGameDefinition(newGameDefinitionMessage, 0));
 }