本文整理汇总了C#中TestRepository类的典型用法代码示例。如果您正苦于以下问题:C# TestRepository类的具体用法?C# TestRepository怎么用?C# TestRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestRepository类属于命名空间,在下文中一共展示了TestRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例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: GetNextChallengeBoardCategory
public void GetNextChallengeBoardCategory()
{
var repository = new TestRepository();
// create a game with some challenges
var board = new Board();
repository.Add(board);
var game = new Game() { BoardId = board.Id };
repository.Add(game);
var category = new ChallengeCategory();
repository.Add(category);
var challenge1 = new Challenge() { ChallengeCategoryId = category.Id };
var challenge2 = new Challenge() { ChallengeCategoryId = category.Id };
var challenge3 = new Challenge() { ChallengeCategoryId = category.Id };
var challenges = new Challenge[] { challenge1, challenge2, challenge3 };
repository.AddAll(challenges);
repository.Add(new BoardChallengeCategory() { BoardId = board.Id, ChallengeCategoryId = category.Id });
// keep getting the next challenge until all challenges should have been used
var usedChallenges = new List<Challenge>();
foreach (Challenge challenge in challenges)
{
usedChallenges.Add(game.GetNextChallenge(0));
}
// verify that all challenges were used
CollectionAssert.AreEqual(challenges.Select(x => x.Id).OrderBy(x => x), usedChallenges.Select(x => x.Id).OrderBy(x => x));
// verify that more challenges can be retrieved
Assert.IsNotNull(game.GetNextChallenge(0));
}
示例4: SyncStatusStartsWithOfflineStatus
public void SyncStatusStartsWithOfflineStatus() {
this.SetupMocks();
var underTest = new TestRepository(this.repoInfo, this.listener, this.queue);
Assert.That(underTest.Status, Is.EqualTo(SyncStatus.Disconnected));
}
示例5: Setup
public void Setup()
{
_testRep = new TestRepository();
_rep = new CachingRepository(_testRep, new TestEventStore());
_aggregate = _testRep.Get<TestAggregate>(Guid.NewGuid());
_rep.Save(_aggregate,-1);
}
示例6: SetUp
public override void SetUp()
{
base.SetUp();
db = CreateBareRepository();
reader = db.NewObjectReader();
test = new TestRepository<FileRepository>(db);
}
示例7: CloneSpace
public void CloneSpace()
{
var repository = new TestRepository();
// create a space
var space = new Space() { BackgroundColorId = 1, BoardId = 2, Height = 3, ImageId = 4, Order = 5, TextColorId = 6, Type = SpaceType.TurnAround, Width = 7, X = 8, Y = 9, IconId = 11 };
repository.Add(space);
// clone the space
var clonedSpace = space.Clone();
// verify that space was cloned
Assert.AreNotEqual(space.Id, clonedSpace.Id);
Assert.AreEqual(clonedSpace.BackgroundColorId, space.BackgroundColorId);
Assert.AreEqual(clonedSpace.BoardId, space.BoardId);
Assert.AreEqual(clonedSpace.Height, space.Height);
Assert.AreEqual(clonedSpace.ImageId, space.ImageId);
Assert.AreEqual(clonedSpace.Name, space.Name);
Assert.AreEqual(clonedSpace.Order, space.Order);
Assert.AreEqual(clonedSpace.TextColorId, space.TextColorId);
Assert.AreEqual(clonedSpace.Type, space.Type);
Assert.AreEqual(clonedSpace.Width, space.Width);
Assert.AreEqual(clonedSpace.X, space.X);
Assert.AreEqual(clonedSpace.Y, space.Y);
Assert.AreEqual(clonedSpace.IconId, space.IconId);
}
示例8: CopyBoard
public void CopyBoard()
{
var repository = new TestRepository();
// create a board and associated data
var board = CreateBoardData(repository);
// copy the board
var copiedBoard = board.Copy();
// verify that the board and spaces are copied, and challenge links are copied but challenges are the same
Assert.AreNotEqual(board.Id, copiedBoard.Id);
Assert.AreEqual(board.ImageId, copiedBoard.ImageId);
Assert.AreEqual(board.Active, copiedBoard.Active);
Assert.AreEqual(board.Description, copiedBoard.Description);
Assert.AreEqual(board.Name, copiedBoard.Name);
Assert.AreEqual(board.OwnerId, copiedBoard.OwnerId);
Assert.AreEqual(board.TurnsToEnd, copiedBoard.TurnsToEnd);
Assert.AreEqual(board.NameCardsToEnd, copiedBoard.NameCardsToEnd);
Assert.AreEqual(board.SafeHavenCardsToEnd, copiedBoard.SafeHavenCardsToEnd);
Assert.AreNotEqual(board.Spaces.Select(x => x.Id), copiedBoard.Spaces.Select(x => x.Id));
Assert.AreEqual(board.Spaces.Select(x => copiedBoard.Id), copiedBoard.Spaces.Select(x => x.BoardId));
Assert.AreEqual(board.Spaces.Select(x => x.Order), copiedBoard.Spaces.Select(x => x.Order));
Assert.AreNotEqual(board.Spaces.Select(x => x.ChallengeCategories.Select(y => y.Id)), copiedBoard.Spaces.Select(x => x.ChallengeCategories.Select(y => y.Id)));
Assert.AreEqual(board.Spaces.Select(x => x.ChallengeCategories.Select(y => repository.Get<ChallengeCategory>(y.ChallengeCategoryId).Id)), copiedBoard.Spaces.Select(x => x.ChallengeCategories.Select(y => repository.Get<ChallengeCategory>(y.ChallengeCategoryId).Id)));
Assert.AreEqual(board.Challenges.Select(x => x.Id), copiedBoard.Challenges.Select(x => x.Id));
}
示例9: RecentMessages
public void RecentMessages()
{
var repository = new TestRepository();
// create a player with some messages
var player = new Player();
repository.Add(player);
var message1 = new Message() { PlayerId = player.Id };
var message2 = new Message() { PlayerId = player.Id };
var message3 = new Message() { PlayerId = player.Id };
var message4 = new Message() { PlayerId = player.Id };
var message5 = new Message() { PlayerId = player.Id };
repository.Add(message1);
repository.Add(message2);
repository.Add(message3);
repository.Add(message4);
repository.Add(message5);
// verify that the correct messages are returned and in the correct order
var expectedMessages = new Message[] { message5, message4, message3 }.Select(x => x.Id);
var recentMessages = player.RecentMessages(3).Select(x => x.Id);
Assert.AreEqual(expectedMessages, recentMessages);
// add more messages
var message6 = new Message() { PlayerId = player.Id };
var message7 = new Message() { PlayerId = player.Id };
repository.Add(message6);
repository.Add(message7);
// verify that the correct messages are returned and in the correct order
expectedMessages = new Message[] { message7, message6, message5 }.Select(x => x.Id);
recentMessages = player.RecentMessages(3).Select(x => x.Id);
Assert.AreEqual(expectedMessages, recentMessages);
}
示例10: SetUp
public override void SetUp()
{
base.SetUp();
tr = new TestRepository<Repository>(db);
reader = db.NewObjectReader();
inserter = db.NewObjectInserter();
}
示例11: SelectSamePiece
public void SelectSamePiece()
{
var repository = new TestRepository();
var game = SetupGame(repository);
// select a piece
var piece = repository.FindAll<Piece>().First();
var color = repository.FindAll<Color>().First();
var player1 = game.Players.First();
var action1 = player1.Actions.Where(x => x.Type == ActionType.SelectPiece).Single();
action1.PerformAction(string.Format("{{'PieceId':'{0}','ColorId':'{1}'}}", piece.Id, color.Id));
// select the same combo of piece/color with another player
var player2 = game.Players.Where(x => x.Actions.Where(y => y.Type == ActionType.SelectPiece).Count() > 0).First();
var action2 = player2.Actions.Where(x => x.Type == ActionType.SelectPiece).Single();
action2.PerformAction(string.Format("{{'PieceId':'{0}','ColorId':'{1}'}}", piece.Id, color.Id));
// verify that no piece was selected
player2 = repository.Get<Player>(player2.Id);
Assert.AreEqual(0, player2.ColorId);
Assert.AreEqual(0, player2.PieceId);
Assert.IsNotEmpty(player2.Actions.Where(x => x.Type == ActionType.SelectPiece));
var message = player2.Messages.Single();
Assert.AreEqual("Another player has the same piece. Please choose another picture and/or color.", message.Text);
}
示例12: When_saving_aggregate
public When_saving_aggregate()
{
_testRep = new TestRepository();
_rep = new CacheRepository(_testRep, new TestInMemoryEventStore(), new CqrsMemoryCache());
_aggregate = _testRep.Get<TestAggregate>(Guid.NewGuid());
_aggregate.DoSomething();
_rep.Save(_aggregate, -1);
}
示例13: SetUp
public override void SetUp()
{
base.SetUp();
testDb = new TestRepository(db);
df = new DiffFormatter(DisabledOutputStream.INSTANCE);
df.SetRepository(db);
df.SetAbbreviationLength(8);
}
示例14: DataApi
public DataApi()
{
var dbContext = new InterviewQContext();
Tests = new TestRepository(dbContext);
Questions = new QuestionRepository(dbContext);
DifficultyLevels = new DifficultyLevelRepository(dbContext);
Catagories = new CatagoryRepository(dbContext);
}
示例15: Setup
public void Setup()
{
_repository = new TestRepository<EntityObject>();
_entity = new EntityObject
{
Name = "Candy",
Description = "Delicious"
};
}