Inheritance: ApiFriendlyException
        public void ItThrowsAnEntityDoesNotExistExceptionIfThePassedInUserDoesntExistYet()
        {
            BuildDataContextMock(false, true, true);
            var expectedException = new EntityDoesNotExistException(typeof(ApplicationUser), currentUser.Id);

            Exception actualException = Assert.Throws<EntityDoesNotExistException>(
                () => gamingGroupInviteConsumer.AddNewUserToGamingGroup(currentUser.Id, invitationId));

            Assert.That(expectedException.Message, Is.EqualTo(actualException.Message));
        }
        public async Task ItReturnsTheStatusCodeAndMessageIfItIsHandlingAnApiExceptionFilter()
        {
            var expectedException = new EntityDoesNotExistException(typeof(Player), "some id");
            context.Exception = expectedException;

            autoMocker.ClassUnderTest.OnException(context);

            Assert.That(context.Response.StatusCode, Is.EqualTo(expectedException.StatusCode));
            Assert.That(await context.Response.Content.ReadAsStringAsync(),Does.Contain(expectedException.Message));
        }
        public void ItThrowsAnEntityNotFoundIfTheGamingGroupInvitationDoesNotExist()
        {
            this.SetupMocks(false, true, true, true);
            var expectedException = new EntityDoesNotExistException(typeof(GamingGroupInvitation), gamingGroupInvitationId);

            Exception actualException = Assert.Throws<EntityDoesNotExistException>(
                () => gamingGroupInviteConsumer.AddExistingUserToGamingGroup(this.gamingGroupInvitationId.ToString()));

            Assert.That(actualException.Message.Equals(expectedException.Message));
        }
Esempio n. 4
0
        public void It_Throws_An_EntityDoesNotExistException_If_The_BoardGameGeekId_Doesnt_Map_To_A_Record()
        {
            //--arrange
            int invalidBoardGameGeekGameDefinitionId = -100;
            var expectedException = new EntityDoesNotExistException(typeof(BoardGameGeekGameDefinition), invalidBoardGameGeekGameDefinitionId);

            //--act
            var exception = Assert.Throws<EntityDoesNotExistException>(() => _autoMocker.ClassUnderTest.GetFromSource(invalidBoardGameGeekGameDefinitionId));

            //--assert
            exception.Message.ShouldBe(expectedException.Message);
        }
        public void ItThrowsAnEntityDoesNotExistExceptionIfTheIdIsInvalid()
        {
            int invalidId = -1;
            var expectedException = new EntityDoesNotExistException(typeof(PlayedGame), invalidId);

            using (NemeStatsDataContext dataContext = new NemeStatsDataContext())
            {
                PlayedGameRetriever retriever = new PlayedGameRetriever(dataContext);

                Exception actualException = Assert.Throws<EntityDoesNotExistException>(() => retriever.GetPlayedGameDetails(invalidId));

                Assert.That(expectedException.Message, Is.EqualTo(actualException.Message));
            }
        }
        public void ItThrowsAnEntityDoesNotExistExceptionIfTheIdIsntValid()
        {
            using (dbContext = new NemeStatsDbContext())
            {
                using (dataContext = new NemeStatsDataContext(dbContext, securedEntityValidatorFactory))
                {
                    var playerRepository = new EntityFrameworkPlayerRepository(dataContext);

                    int invalidId = -1;
                    var expectedException = new EntityDoesNotExistException(typeof(GameDefinition), invalidId);
                    var cacheableGameDataRetriever = new BoardGameGeekGameDefinitionInfoRetriever(new DateUtilities(), new CacheService(), dataContext);

                    var gameDefinitionRetriever = new GameDefinitionRetriever(dataContext, playerRepository, cacheableGameDataRetriever);

                    var actualException = Assert.Throws<EntityDoesNotExistException>(() => 
                        gameDefinitionRetriever.GetGameDefinitionDetails(invalidId, 0));

                    actualException.Message.ShouldBe(expectedException.Message);
                }
            }
        }
 public void ItThrowsAnEntityDoesNotExistExceptionIfThePlayerDoesNotExist()
 {
     const int invalidPlayerId = -1;
     var expectedException = new EntityDoesNotExistException(typeof(Player), invalidPlayerId);
     Exception actualException = Assert.Throws<EntityDoesNotExistException>(
                                                                     () => autoMocker.ClassUnderTest.GetPlayerDetails(
                                                                         invalidPlayerId, 
                                                                         0));
     
     Assert.AreEqual(expectedException.Message, actualException.Message);
 }
        public void It_Throws_An_EntityDoesNotExistException_If_The_Specified_Played_Game_Id_Does_Not_Match_An_Existing_Game()
        {
            //--arrange
            autoMocker.Get<IDataContext>().Expect(mock => mock.GetQueryable<PlayedGame>()).Return(new List<PlayedGame>().AsQueryable());

            var playerRanks = new List<PlayerRank>();
            var updatedGame = new UpdatedGame
            {
                GameDefinitionId = gameDefinition.Id,
                PlayerRanks = playerRanks,
                PlayedGameId = -1
            };
            var expectedException = new EntityDoesNotExistException(typeof(PlayedGame), updatedGame.PlayedGameId);

            //--act
            var actualException = Assert.Throws<EntityDoesNotExistException>(
                () => autoMocker.ClassUnderTest.UpdatePlayedGame(updatedGame, TransactionSource.RestApi, currentUser));

            //--assert
            actualException.Message.ShouldBe(expectedException.Message);
        }