public void Can_Edit_Game() { //Arrange using (var factory = new SQLiteDbContextFactory()) { using (var context = factory.CreateContext()) { context.Games.Add(new Game { GameId = 1, Title = "TestToModify" }); context.SaveChanges(); } //Act using (var context = factory.CreateContext()) { var gameRepository = new EFGameRepository(context); gameRepository.SaveGame(new Game { GameId = 1, Title = "TestAfterModification" }); } //Assert using (var context = factory.CreateContext()) { Assert.Equal(1, context.Games.Count()); Assert.Equal("TestAfterModification", context.Games.Single().Title); Assert.Equal(1, context.Games.Single().GameId); } } }
public void Can_Add_Game() { //Arrange using (var factory = new SQLiteDbContextFactory()) { //Act // Run the test against one instance of the context using (var context = factory.CreateContext()) { var gameRepository = new EFGameRepository(context); gameRepository.SaveGame(new Game { Title = "TestToAdd" }); } //Assert // Use a separate instance of the context to verify correct data was saved to database using (var context = factory.CreateContext()) { Assert.Equal(1, context.Games.Count()); Assert.Equal("TestToAdd", context.Games.Single().Title); } } }