public void DeletePlayer() { var repository = new TestRepository(); // create players with actions, cards, and messages var player1 = CreatePlayerData(repository); var player2 = CreatePlayerData(repository); var player3 = CreatePlayerData(repository); // delete a player player1.Delete(); // verify all related data is deleted VerifyPlayerDataDeleted(player1, repository); // verify that other player data was not deleted Assert.IsNotEmpty(repository.Find<Haven.Action>(x => x.OwnerId == player2.Id)); Assert.IsNotEmpty(repository.Find<PlayerNameCard>(x => x.PlayerId == player2.Id)); Assert.IsNotEmpty(repository.Find<PlayerSafeHavenCard>(x => x.PlayerId == player2.Id)); Assert.IsNotEmpty(repository.Find<Message>(x => x.PlayerId == player2.Id)); }
public void DeleteGame() { var repository = new TestRepository(); // create games with players and used challenges var game1 = CreateGameData(repository); var game2 = CreateGameData(repository); // delete a game game1.Delete(); // verify that the game is deleted Assert.IsEmpty(repository.Find<Game>(x => x.Id == game1.Id)); // verify that players are deleted Assert.IsEmpty(repository.Find<Player>(x => x.GameId == game1.Id)); // verify that challenges are not marked as used Assert.IsEmpty(repository.Find<UsedChallenge>(x => x.GameId == game1.Id)); // verify that data from other game is not deleted Assert.IsNotEmpty(repository.Find<Game>(x => x.Id == game2.Id)); Assert.IsNotEmpty(repository.Find<Player>(x => x.GameId == game2.Id)); Assert.IsNotEmpty(repository.Find<UsedChallenge>(x => x.GameId == game2.Id)); }
public void DeleteChallenge() { var repository = new TestRepository(); // add test challenges var challenge1 = new Challenge() { Question = "Test Question 1" }; var challenge2 = new Challenge() { Question = "Test Question 2" }; repository.Add(challenge1); repository.Add(challenge2); // add answers var answer1a = new ChallengeAnswer() { Answer = "Test Answer 1a", Correct = true, ChallengeId = challenge1.Id }; var answer1b = new ChallengeAnswer() { Answer = "Test Answer 1b", Correct = false, ChallengeId = challenge1.Id }; var answer2a = new ChallengeAnswer() { Answer = "Test Answer 2a", Correct = true, ChallengeId = challenge2.Id }; var answer2b = new ChallengeAnswer() { Answer = "Test Answer 2b", Correct = false, ChallengeId = challenge2.Id }; repository.AddAll(new ChallengeAnswer[] { answer1a, answer1b, answer2a, answer2b }); // delete one challenge challenge1.Delete(); // verify challenge and answers are deleted Assert.IsEmpty(repository.Find<Challenge>(x => x.Id == challenge1.Id)); Assert.IsEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer1a.Id)); Assert.IsEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer1b.Id)); // verify other challenge is not deleted Assert.IsNotEmpty(repository.Find<Challenge>(x => x.Id == challenge2.Id)); Assert.IsNotEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer2a.Id)); Assert.IsNotEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer2b.Id)); }
public void DeleteEmptyGame() { var repository = new TestRepository(); // create a game without players or used challenges var game = new Game(); repository.Add(game); // delete the game game.Delete(); // verify that deletion works Assert.IsEmpty(repository.Find<Game>(x => x.Id == game.Id)); }
public void DeleteSpace() { var repository = new TestRepository(); // create spaces var space1 = new Space(); var space2 = new Space(); repository.AddAll(new Space[] { space1, space2 }); // delete a space space1.Delete(); // verify that space is deleted Assert.IsEmpty(repository.Find<Space>(x => x.Id == space1.Id)); // verify that other space is not deleted Assert.IsNotEmpty(repository.Find<Space>(x => x.Id == space2.Id)); }
public void DeletedSpaceWithCategories() { var repository = new TestRepository(); // create a space with category links var space = new Space(); repository.Add(space); repository.Add(new SpaceChallengeCategory() { SpaceId = space.Id, ChallengeCategoryId = 1 }); repository.Add(new SpaceChallengeCategory() { SpaceId = space.Id, ChallengeCategoryId = 2 }); // delete a space space.Delete(); // verify that space is deleted Assert.IsEmpty(repository.Find<Space>(x => x.Id == space.Id)); // verify that category links are deleted Assert.IsEmpty(repository.Find<SpaceChallengeCategory>(x => x.SpaceId == space.Id)); }
public void DeletedSafeHavenSpace() { var repository = new TestRepository(); // create safe haven spaces var safeHavenCard1 = new SafeHavenCard(); var safeHavenCard2 = new SafeHavenCard(); repository.AddAll(new SafeHavenCard[] { safeHavenCard1, safeHavenCard2 }); var space1 = new Space() { SafeHavenCardId = safeHavenCard1.Id }; var space2 = new Space() { SafeHavenCardId = safeHavenCard2.Id }; repository.AddAll(new Space[] { space1, space2 }); // delete a space space1.Delete(); // verify that space is deleted Assert.IsEmpty(repository.Find<Space>(x => x.Id == space1.Id)); // verify that safe haven card is deleted Assert.IsEmpty(repository.Find<SafeHavenCard>(x => x.Id == space1.SafeHavenCardId)); // verify that other space data is not deleted Assert.IsNotEmpty(repository.Find<Space>(x => x.Id == space2.Id)); Assert.IsNotEmpty(repository.Find<SafeHavenCard>(x => x.Id == space2.SafeHavenCardId)); }
public void DeletedChallengeSpace() { var repository = new TestRepository(); // create challenge spaces var nameCard1 = new NameCard(); var nameCard2 = new NameCard(); repository.AddAll(new NameCard[] { nameCard1, nameCard2 }); var space1 = new Space() { NameCardId = nameCard1.Id }; var space2 = new Space() { NameCardId = nameCard2.Id }; repository.AddAll(new Space[] { space1, space2 }); // delete a space space1.Delete(); // verify that space is deleted Assert.IsEmpty(repository.Find<Space>(x => x.Id == space1.Id)); // verify that name card is deleted Assert.IsEmpty(repository.Find<NameCard>(x => x.Id == space1.NameCardId)); // verify that other space data is not deleted Assert.IsNotEmpty(repository.Find<Space>(x => x.Id == space2.Id)); Assert.IsNotEmpty(repository.Find<NameCard>(x => x.Id == space2.NameCardId)); }
public void DeleteEmptyBoard() { var repository = new TestRepository(); // create a board without any associated data var board = new Board(); repository.Add(board); // verify that deletion works board.Delete(); Assert.IsEmpty(repository.Find<Board>(x => x.Id == board.Id)); }
public void DeleteBoard() { var repository = new TestRepository(); // create some boards and associated data var board1 = CreateBoardData(repository); var board2 = CreateBoardData(repository); // delete the board board1.Delete(); // verify that the board is deleted Assert.IsEmpty(repository.Find<Board>(x => x.Id == board1.Id)); // verify that associated data is deleted Assert.IsEmpty(repository.Find<Image>(x => x.Id == board1.ImageId)); Assert.IsEmpty(board1.Challenges); Assert.IsEmpty(board1.Spaces); // verify that other board data is not deleted Assert.IsNotEmpty(repository.Find<Board>(x => x.Id == board2.Id)); Assert.IsNotEmpty(repository.Find<Image>(x => x.Id == board2.ImageId)); Assert.IsNotEmpty(board2.Challenges); Assert.IsNotEmpty(board2.Spaces); }