本文整理汇总了C#中TestRepository类的典型用法代码示例。如果您正苦于以下问题:C# TestRepository类的具体用法?C# TestRepository怎么用?C# TestRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestRepository类属于命名空间,在下文中一共展示了TestRepository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:nfink,项目名称:Haven,代码行数:30,代码来源:ChallengeTests.cs
示例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));
}
开发者ID:nfink,项目名称:Haven,代码行数:25,代码来源:GameTests.cs
示例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));
}
开发者ID:nfink,项目名称:Haven,代码行数:31,代码来源:GameTests.cs
示例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));
}
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:7,代码来源:RepositoryTests.cs
示例5: Setup
public void Setup()
{
_testRep = new TestRepository();
_rep = new CachingRepository(_testRep, new TestEventStore());
_aggregate = _testRep.Get<TestAggregate>(Guid.NewGuid());
_rep.Save(_aggregate,-1);
}
开发者ID:rjygraham,项目名称:CQRSlite,代码行数:7,代码来源:When_saving_aggregate.cs
示例6: SetUp
public override void SetUp()
{
base.SetUp();
db = CreateBareRepository();
reader = db.NewObjectReader();
test = new TestRepository<FileRepository>(db);
}
开发者ID:shoff,项目名称:ngit,代码行数:7,代码来源:AbbreviationTest.cs
示例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);
}
开发者ID:nfink,项目名称:Haven,代码行数:26,代码来源:SpaceTests.cs
示例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));
}
开发者ID:nfink,项目名称:Haven,代码行数:27,代码来源:BoardTests.cs
示例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);
}
开发者ID:nfink,项目名称:Haven,代码行数:34,代码来源:PlayerTests.cs
示例10: SetUp
public override void SetUp()
{
base.SetUp();
tr = new TestRepository<Repository>(db);
reader = db.NewObjectReader();
inserter = db.NewObjectInserter();
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:7,代码来源:NoteMapTest.cs
示例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);
}
开发者ID:nfink,项目名称:Haven,代码行数:26,代码来源:SelectionPieceActionTests.cs
示例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);
}
开发者ID:henningst,项目名称:CQRSlite,代码行数:8,代码来源:When_saving_aggregate.cs
示例13: SetUp
public override void SetUp()
{
base.SetUp();
testDb = new TestRepository(db);
df = new DiffFormatter(DisabledOutputStream.INSTANCE);
df.SetRepository(db);
df.SetAbbreviationLength(8);
}
开发者ID:ashmind,项目名称:ngit,代码行数:8,代码来源:DiffFormatterTest.cs
示例14: DataApi
public DataApi()
{
var dbContext = new InterviewQContext();
Tests = new TestRepository(dbContext);
Questions = new QuestionRepository(dbContext);
DifficultyLevels = new DifficultyLevelRepository(dbContext);
Catagories = new CatagoryRepository(dbContext);
}
开发者ID:ravindranathw,项目名称:InterviewQ,代码行数:8,代码来源:DataAPI.cs
示例15: Setup
public void Setup()
{
_repository = new TestRepository<EntityObject>();
_entity = new EntityObject
{
Name = "Candy",
Description = "Delicious"
};
}
开发者ID:criticalbreakpoint,项目名称:Architecture,代码行数:9,代码来源:RepositoryFixture.cs
示例16: FootlooseFSTestUnitOfWork
public FootlooseFSTestUnitOfWork()
{
List<Person> persons = TestDataStore.GetPersonTestData();
_persons = new TestRepository<Person>();
foreach (Person person in persons)
_persons.Add(person);
}
开发者ID:rasmith2001,项目名称:FootlooseFinancialServices,代码行数:9,代码来源:FootlooseFSTestUnitOfWork.cs
示例17: Execute
public void Execute(IJobExecutionContext context)
{
using (var testRepository = new TestRepository())
{
using (var codeRepository = new CodeRepository())
{
using (var resultRepository = new ResultRepository())
{
ICompiler compiler = new CSharpCompiler();
var processBuilder = new ProcessBuilder();
var runer = new Runer();
List<Code> codes = codeRepository.ExtractAll().ToList();
codes.ForEach(item =>
{
if (!compiler.TryCompile(item.Text, @"F://test.exe"))
{
resultRepository.Add(new TestDatabase.Entities.Result(item.Id, "compilation error"));
}
else
{
var tests = testRepository.GetTestsByTaskId(item.TaskId).ToList();
for (var i = 0; i < tests.Count; i++)
{
var proc = processBuilder.Create(@"F://test.exe");
string output;
try
{
if (!runer.TryGetResult(proc, tests[i].Input, out output))
{
resultRepository.Add(new TestDatabase.Entities.Result(item.Id,
"out of time on test " + (i + 1).ToString()));
return;
}
}
catch (Exception e)
{
resultRepository.Add(new TestDatabase.Entities.Result(item.Id,
"out of memory on test " + (i + 1).ToString()));
return;
}
if (output == tests[i].Output) continue;
resultRepository.Add(new TestDatabase.Entities.Result(item.Id,
"wrong answer on test " + (i + 1).ToString()));
return;
}
resultRepository.Add(new TestDatabase.Entities.Result(item.Id,
"success"));
}
});
}
}
}
}
开发者ID:LexaGal,项目名称:TestSystem,代码行数:56,代码来源:Server.cs
示例18: SetUp
public override void SetUp()
{
base.SetUp();
tr = new TestRepository<Repository>(db);
reader = db.NewObjectReader();
inserter = db.NewObjectInserter();
merger = new DefaultNoteMerger();
noteOn = tr.Blob("a");
baseNote = NewNote("data");
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:10,代码来源:DefaultNoteMergerTest.cs
示例19: AddEmployee_Get_Should_Return_Add_Employee_View
public void AddEmployee_Get_Should_Return_Add_Employee_View()
{
var testRepository = new TestRepository();
var employeeController = new EmployeeController(testRepository);
var result = employeeController.AddEmployee();
Assert.IsNotNull(result);
Assert.AreEqual( "AddEmployee", ((ViewResult)result).ViewName);
}
开发者ID:preetil,项目名称:Test,代码行数:10,代码来源:EmploeeControllerTest.cs
示例20: CanGetAllEntities
public void CanGetAllEntities()
{
// Arrange
var repo = new TestRepository( Session );
// Act
var all = repo.GetAll().ToArray();
// Assert
Assert.AreEqual( TestData.Length, all.Length );
}
开发者ID:TheSylence,项目名称:GSD,代码行数:11,代码来源:RepositoryTests.cs
注:本文中的TestRepository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论