public void ItUpdatesTheActiveFlag()
        {
            var gameDefinitionUpdateRequest = new GameDefinitionUpdateRequest
            {
                Active = true
            };

            autoMocker.ClassUnderTest.UpdateGameDefinition(gameDefinitionUpdateRequest, currentUser);

            autoMocker.Get <IDataContext>().AssertWasCalled(dataContext => dataContext.Save(
                                                                Arg <GameDefinition> .Matches(gameDefinition => gameDefinition.Active == gameDefinitionUpdateRequest.Active),
                                                                Arg <ApplicationUser> .Is.Same(currentUser)));
        }
        public void ItUpdatesTheGameDefinitionDescription()
        {
            var gameDefinitionUpdateRequest = new GameDefinitionUpdateRequest
            {
                Description = "some description"
            };

            autoMocker.ClassUnderTest.UpdateGameDefinition(gameDefinitionUpdateRequest, currentUser);

            autoMocker.Get <IDataContext>().AssertWasCalled(dataContext => dataContext.Save(
                                                                Arg <GameDefinition> .Matches(gameDefinition => gameDefinition.Description == gameDefinitionUpdateRequest.Description),
                                                                Arg <ApplicationUser> .Is.Same(currentUser)));
        }
        public void ItDoesNotUpdateTheBoardGameGeekGameDefinitionIdIfTheGameIsNotValid()
        {
            var gameDefinitionUpdateRequest = new GameDefinitionUpdateRequest
            {
                BoardGameGeekGameDefinitionId = 200
            };

            autoMocker.Get <IBoardGameGeekGameDefinitionCreator>().Expect(
                mock => mock.CreateBoardGameGeekGameDefinition(gameDefinitionUpdateRequest.BoardGameGeekGameDefinitionId.Value))
            .Return(null);

            autoMocker.ClassUnderTest.UpdateGameDefinition(gameDefinitionUpdateRequest, currentUser);

            autoMocker.Get <IDataContext>().AssertWasNotCalled(dataContext => dataContext.Save(
                                                                   Arg <GameDefinition> .Matches(gameDefinition => gameDefinition.BoardGameGeekGameDefinitionId == gameDefinitionUpdateRequest.BoardGameGeekGameDefinitionId),
                                                                   Arg <ApplicationUser> .Is.Same(currentUser)));
        }
Пример #4
0
        public void ItCreatesANewBoardGameGeekGameDefinitionAndLinksToItIfItWasSuccessfullyCreated()
        {
            var gameDefinitionUpdateRequest = new GameDefinitionUpdateRequest
            {
                BoardGameGeekGameDefinitionId = 200
            };

            autoMocker.Get <IBoardGameGeekGameDefinitionCreator>().Expect(
                mock => mock.CreateBoardGameGeekGameDefinition(gameDefinitionUpdateRequest.BoardGameGeekGameDefinitionId.Value, currentUser))
            .Return(gameDefinitionUpdateRequest.BoardGameGeekGameDefinitionId);

            autoMocker.ClassUnderTest.UpdateGameDefinition(gameDefinitionUpdateRequest, currentUser);

            autoMocker.Get <IDataContext>().AssertWasCalled(dataContext => dataContext.Save(
                                                                Arg <GameDefinition> .Matches(gameDefinition => gameDefinition.BoardGameGeekGameDefinitionId == gameDefinitionUpdateRequest.BoardGameGeekGameDefinitionId),
                                                                Arg <ApplicationUser> .Is.Same(currentUser)));
        }
        public HttpResponseMessage UpdateGameDefinition(UpdateGameDefinitionMessage updateGameDefinitionMessage, int gameDefinitionId, int gamingGroupId)
        {
            if (updateGameDefinitionMessage == null)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "You must pass at least one valid parameter.");
            }

            var gameDefinitionUpdateRequest = new GameDefinitionUpdateRequest
            {
                Active = updateGameDefinitionMessage.Active,
                Name = updateGameDefinitionMessage.GameDefinitionName,
                BoardGameGeekGameDefinitionId = updateGameDefinitionMessage.BoardGameGeekGameDefinitionId,
                GameDefinitionId = gameDefinitionId
            };

            _gameDefinitionSaver.UpdateGameDefinition(gameDefinitionUpdateRequest, CurrentUser);

            return Request.CreateResponse(HttpStatusCode.NoContent);
        }