コード例 #1
0
        public async System.Threading.Tasks.Task DeletePlayerTestAsync()
        {
            DbContextOptions <GamesDbContext> options = new DbContextOptionsBuilder <GamesDbContext>().UseInMemoryDatabase("DeletePlayer").Options;

            using (GamesDbContext context = new GamesDbContext(options))
            {
                Player newPlayer = new Player()
                {
                    ID     = "1",
                    RoomID = "1",
                    Name   = "Farkus",
                    Score  = 500,
                    Toad   = true
                };

                context.Add(newPlayer);
                await context.SaveChangesAsync();

                Player foundPlayer = await context.Players.FirstOrDefaultAsync(player => player.ID == "1");

                foundPlayer.Score = 250;

                context.Remove(foundPlayer);
                await context.SaveChangesAsync();

                Player deletedPlayer = await context.Players.FirstOrDefaultAsync(player => player.ID == "1");

                Assert.True(deletedPlayer == null);
            }
        }
コード例 #2
0
 public void DeleteCredential(Credential credential)
 {
     _context.Remove(credential);
 }