public void DeleteUser_InvalidId_EntityDoesNotExistException() { UserManager userManager = new UserManager(); EntityDoesNotExistException expectedException = Assert.Throws <EntityDoesNotExistException>( () => userManager.DeleteUser(-1)); Assert.AreEqual("User with id:'-1' doesn't exist in data base.", expectedException.Message); }
public void ItThrowsAnEntityDoesNotExistExceptionIfTheIdIsInvalid() { var invalidId = -1; var expectedException = new EntityDoesNotExistException(typeof(PlayedGame), invalidId); Exception actualException = Assert.Throws <EntityDoesNotExistException>(() => _playedGameRetriever.GetPlayedGameDetails(invalidId)); Assert.That(expectedException.Message, Is.EqualTo(actualException.Message)); }
public void ItThrowsAnEntityNotFoundIfTheGamingGroupInvitationDoesNotExist() { this.SetupMocks(false, true, true, true); var expectedException = new EntityDoesNotExistException <GamingGroupInvitation>(gamingGroupInvitationId); Exception actualException = Assert.Throws <EntityDoesNotExistException <GamingGroupInvitation> >( () => gamingGroupInviteConsumer.AddExistingUserToGamingGroup(this.gamingGroupInvitationId.ToString())); Assert.That(actualException.Message.Equals(expectedException.Message)); }
public void ItThrowsAnEntityDoesNotExistExceptionIfThePassedInUserDoesntExistYet() { BuildDataContextMock(false, true, true); var expectedException = new EntityDoesNotExistException <ApplicationUser>(currentUser.Id); Exception actualException = Assert.Throws <EntityDoesNotExistException <ApplicationUser> >( () => gamingGroupInviteConsumer.AddNewUserToGamingGroup(currentUser.Id, invitationId)); Assert.That(expectedException.Message, Is.EqualTo(actualException.Message)); }
public void ItThrowsAnEntityDoesNotExistExceptionIfTheIdIsntValid() { int invalidId = -1; var expectedException = new EntityDoesNotExistException <GameDefinition>(invalidId); var gameDefinitionRetriever = GetInstance <GameDefinitionRetriever>(); var actualException = Assert.Throws <EntityDoesNotExistException <GameDefinition> >(() => gameDefinitionRetriever.GetGameDefinitionDetails(invalidId, 0)); actualException.Message.ShouldBe(expectedException.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 ItThrowsAnEntityNotFoundExceptionIfTheInvitationDoesNotExist() { this.SetupMocks(true, false, true, true); var expectedException = new EntityDoesNotExistException(typeof(GamingGroupInvitation), invitation.RegisteredUserId); Exception actualException = Assert.Throws <EntityDoesNotExistException>( () => gamingGroupInviteConsumer.AddExistingUserToGamingGroup(this.gamingGroupInvitationId.ToString())); Assert.That(actualException.Message, Is.EqualTo(expectedException.Message)); }
public void ItThrowsAnEntityDoesNotExistExceptionIfThePlayerOnTheInviteDoesNotExist() { BuildDataContextMock(true, true, false); var expectedException = new EntityDoesNotExistException(typeof(Player), expectedInvitation.PlayerId); Exception actualException = Assert.Throws <EntityDoesNotExistException>( () => gamingGroupInviteConsumer.AddNewUserToGamingGroup(currentUser.Id, invitationId)); Assert.That(expectedException.Message, Is.EqualTo(actualException.Message)); }
public void ItThrowsAnEntityDoesNotExistExceptionIfThePlayerDoesNotExist() { const int invalidPlayerId = -1; var expectedException = new EntityDoesNotExistException <Player>(invalidPlayerId); Exception actualException = Assert.Throws <EntityDoesNotExistException <Player> >( () => _autoMocker.ClassUnderTest.GetPlayerDetails( invalidPlayerId, 0)); Assert.AreEqual(expectedException.Message, actualException.Message); }
public void It_Throws_An_EntityNotFoundException_If_The_Played_Game_Doesnt_Exist() { //--arrange var playedGameIdThatDoesntExist = -1; var expectedException = new EntityDoesNotExistException <PlayedGame>(playedGameIdThatDoesntExist); //--act var exception = Assert.Throws <EntityDoesNotExistException <PlayedGame> >(() => _autoMocker.ClassUnderTest.GetInfoForEditingPlayedGame(playedGameIdThatDoesntExist, _currentUser)); //--assert exception.Message.ShouldBe(expectedException.Message); }
public void GetUserCredentials_InvalidUser_EntityDoesNotExistException() { UserManager userManager = new UserManager(); string salt; string password; EntityDoesNotExistException expectedException = Assert.Throws <EntityDoesNotExistException>( () => userManager.GetUserCredentials(-1, out password, out salt)); Assert.AreEqual("User with ID:'-1' doesn't exist in data base.", expectedException.Message); }
public void It_Throws_An_Entity_Does_Not_Exist_Exception_If_The_BoardGameGeekGameDefinitionId_Isnt_Valid() { //--arrange int invalidId = -1; var expectedException = new EntityDoesNotExistException(typeof(BoardGameGeekGameDefinition), invalidId); //--act var exception = Assert.Throws <EntityDoesNotExistException>(() => AutoMocker.ClassUnderTest.GetFromSource(invalidId)); //--assert exception.Message.ShouldBe(expectedException.Message); }
public void It_Throws_An_EntityDoesNotExistException_If_The_BoardGameGeekId_Doesnt_Map_To_A_Record() { //--arrange int invalidBoardGameGeekGameDefinitionId = -100; var expectedException = new EntityDoesNotExistException <BoardGameGeekGameDefinition>(invalidBoardGameGeekGameDefinitionId); //--act var exception = Assert.Throws <EntityDoesNotExistException <BoardGameGeekGameDefinition> >(() => _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 UpdateUser_InvalidUser_EntityDoesNotExistException() { User user = new User { Email = "*****@*****.**", FirstName = "Sample first name", IsDeleted = false, SecondName = "Sample second name" }; UserManager userManager = new UserManager(); EntityDoesNotExistException expectedException = Assert.Throws <EntityDoesNotExistException>( () => userManager.UpdateUser(user)); Assert.AreEqual("User with ID:'0' doesn't exist in data base.", expectedException.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 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); }
public void GetUserById_DeletedUser_EntityDoesNotExistException() { User user = new User { Email = "*****@*****.**", FirstName = "First name", SecondName = "Second name", IsDeleted = true }; const string Password = "******"; IUserManager userManager = new UserManager(); int userId = userManager.CreateUser(user, Password); EntityDoesNotExistException expectedException = Assert.Throws <EntityDoesNotExistException>( () => userManager.GetUserById(userId)); Assert.AreEqual(string.Format("User with id:'{0}' doesn't exist in data base.", userId), expectedException.Message); }
/// <summary> /// Initializes a new instance of the <see cref="EntityDoesNotExistExceptionTest"/> class. /// </summary> public EntityDoesNotExistExceptionTest() { this.exception = new EntityDoesNotExistException(this.type, this.id); }