public async void CanReadGameSpace() { Microsoft.EntityFrameworkCore.DbContextOptions <SudokuDbContext> options = new DbContextOptionsBuilder <SudokuDbContext>().UseInMemoryDatabase ("ReadGameSpace").Options; using (SudokuDbContext context = new SudokuDbContext(options)) { //Arrange GameSpace gameSpace = new GameSpace(); gameSpace.X = 1; gameSpace.Y = 2; gameSpace.Value = 3; gameSpace.Masked = true; gameSpace.GameBoardID = 1; //Act GameSpaceManager GSM = new GameSpaceManager(context); await GSM.CreateGameSpace(gameSpace); GameSpace result = await GSM.GetGameSpace(gameSpace.X, gameSpace.Y, gameSpace.GameBoardID); Assert.Equal(gameSpace, result); } }
public async void CanUpdateGameSpace() { Microsoft.EntityFrameworkCore.DbContextOptions <SudokuDbContext> options = new DbContextOptionsBuilder <SudokuDbContext>().UseInMemoryDatabase ("UpdateGameSpace").Options; using (SudokuDbContext context = new SudokuDbContext(options)) { //Arrange GameSpace gameSpace = new GameSpace(); gameSpace.X = 1; gameSpace.Y = 2; gameSpace.Value = 3; gameSpace.Masked = true; gameSpace.GameBoardID = 1; //Act GameSpaceManager GSM = new GameSpaceManager(context); await GSM.CreateGameSpace(gameSpace); await GSM.UpdateGameSpace(gameSpace); var result = context.GameSpaces.FirstOrDefault(g => g.X == 1 && g.Y == 2 && g.Value == 3 && g.Masked && g.GameBoardID == 1); Assert.Equal(gameSpace, result); } }