本文整理汇总了C#中TestRepository.Find方法的典型用法代码示例。如果您正苦于以下问题:C# TestRepository.Find方法的具体用法?C# TestRepository.Find怎么用?C# TestRepository.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestRepository
的用法示例。
在下文中一共展示了TestRepository.Find方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeletePlayer
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));
}
示例2: DeleteGame
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));
}
示例3: DeleteChallenge
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));
}
示例4: DeleteEmptyGame
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));
}
示例5: DeleteSpace
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));
}
示例6: DeletedSpaceWithCategories
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));
}
示例7: DeletedSafeHavenSpace
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));
}
示例8: DeletedChallengeSpace
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));
}
示例9: DeleteEmptyBoard
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));
}
示例10: DeleteBoard
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);
}