public void GetPlayersLastChoice_ReturnsExpectedItem() { // Arrange - Set up InMemory DB and add some mock data var options = new DbContextOptionsBuilder <RockPaperScissorsContext>() .UseInMemoryDatabase(databaseName: "LastChoiceDb") .Options; using (var context = new RockPaperScissorsContext(options)) { _gameRepository = new GameRepository(context); context.Add(MatchMocks.MatchWithThreeGames); context.SaveChanges(); } // Act - Use a separate instance of the context to verify correct data was saved to database using (var context = new RockPaperScissorsContext(options)) { // Arrange var gameRepository = new GameRepository(context); var player = context.TacticalComputers.Single(); // Act var gameItem = gameRepository.GetPlayersLastChoice(player); // Assert Assert.AreEqual(3, gameItem.Id); } }
public void Create_AddsItemToDb() { // Arrange - Set up InMemory DB and add some mock data var options = new DbContextOptionsBuilder <RockPaperScissorsContext>() .UseInMemoryDatabase(databaseName: "CreateItemDb") .Options; // Act using (var context = new RockPaperScissorsContext(options)) { _gameRepository = new GameRepository(context); _gameRepository.Create(MatchMocks.MatchWithTwoGames); } // Assert - Use a separate instance of the context to verify correct data was saved to database using (var context = new RockPaperScissorsContext(options)) { Assert.AreEqual(1, context.Matches.Count()); Assert.AreEqual(1, context.Matches.Single().Id); } }
public void GetById_ReturnsItemFromDb() { // Arrange - Set up InMemory DB and add some mock data var options = new DbContextOptionsBuilder <RockPaperScissorsContext>() .UseInMemoryDatabase(databaseName: "getById") .Options; using (var context = new RockPaperScissorsContext(options)) { _gameRepository = new GameRepository(context); _gameRepository.Create(MatchMocks.MatchWithTwoGames); } // Use a separate instance of the context to verify correct data was pulled from database using (var context = new RockPaperScissorsContext(options)) { // Act _gameRepository = new GameRepository(context); var match = _gameRepository.GetById <Model.Match>(1); // Assert Assert.AreEqual(1, match.Id); } }
public RoundRepository(RockPaperScissorsContext context) : base(context) { }
public Repository(RockPaperScissorsContext dbContext) { _dbContext = dbContext; }
public EntityBaseRepository(RockPaperScissorsContext context) { _context = context; }
public LoggingRepository(RockPaperScissorsContext context) : base(context) { }
public PlayerRepository(RockPaperScissorsContext context) : base(context) { }
public GameRepository(RockPaperScissorsContext dbContext) : base(dbContext) { }