private static async Task Delete_clears_all_in_memory_data_test(bool async)
        {
            using (var context = new FraggleContext())
            {
                context.Fraggles.AddRange(
                    new[]
                {
                    new Fraggle {
                        Id = 1, Name = "Gobo"
                    },
                    new Fraggle {
                        Id = 2, Name = "Monkey"
                    },
                    new Fraggle {
                        Id = 3, Name = "Red"
                    },
                    new Fraggle {
                        Id = 4, Name = "Wembley"
                    },
                    new Fraggle {
                        Id = 5, Name = "Boober"
                    },
                    new Fraggle {
                        Id = 6, Name = "Uncle Traveling Matt"
                    }
                });

                await context.SaveChangesAsync();
            }

            using (var context = new FraggleContext())
            {
                Assert.Equal(6, await context.Fraggles.CountAsync());

                if (async)
                {
                    Assert.True(await context.Database.EnsureDeletedAsync());
                }
                else
                {
                    Assert.True(context.Database.EnsureDeleted());
                }

                Assert.Equal(0, await context.Fraggles.CountAsync());
            }

            using (var context = new FraggleContext())
            {
                Assert.Equal(0, await context.Fraggles.CountAsync());

                if (async)
                {
                    Assert.False(await context.Database.EnsureDeletedAsync());
                }
                else
                {
                    Assert.False(context.Database.EnsureDeleted());
                }
            }
        }
        private static async Task Delete_clears_all_in_memory_data_test(bool async)
        {
            using (var context = new FraggleContext())
            {
                context.Fraggles.AddRange(
                    new[]
                        {
                            new Fraggle { Id = 1, Name = "Gobo" },
                            new Fraggle { Id = 2, Name = "Monkey" },
                            new Fraggle { Id = 3, Name = "Red" },
                            new Fraggle { Id = 4, Name = "Wembley" },
                            new Fraggle { Id = 5, Name = "Boober" },
                            new Fraggle { Id = 6, Name = "Uncle Traveling Matt" }
                        });

                await context.SaveChangesAsync();
            }

            using (var context = new FraggleContext())
            {
                Assert.Equal(6, await context.Fraggles.CountAsync());

                if (async)
                {
                    Assert.True(await context.Database.EnsureDeletedAsync());
                }
                else
                {
                    Assert.True(context.Database.EnsureDeleted());
                }

                Assert.Equal(0, await context.Fraggles.CountAsync());
            }

            using (var context = new FraggleContext())
            {
                Assert.Equal(0, await context.Fraggles.CountAsync());

                if (async)
                {
                    Assert.False(await context.Database.EnsureDeletedAsync());
                }
                else
                {
                    Assert.False(context.Database.EnsureDeleted());
                }
            }
        }
        private static async Task Delete_clears_all_in_memory_data_test(bool useEnsureMethod, bool async)
        {
            using (var context = new FraggleContext())
            {
                context.Fraggles.AddRange(
                    new[]
                {
                    new Fraggle {
                        Id = 1, Name = "Gobo"
                    },
                    new Fraggle {
                        Id = 2, Name = "Monkey"
                    },
                    new Fraggle {
                        Id = 3, Name = "Red"
                    },
                    new Fraggle {
                        Id = 4, Name = "Wembley"
                    },
                    new Fraggle {
                        Id = 5, Name = "Boober"
                    },
                    new Fraggle {
                        Id = 6, Name = "Uncle Traveling Matt"
                    }
                });

                await context.SaveChangesAsync();
            }

            using (var context = new FraggleContext())
            {
                Assert.Equal(6, await context.Fraggles.CountAsync());

                if (async)
                {
                    if (useEnsureMethod)
                    {
                        Assert.True(await context.Database.EnsureDeletedAsync());
                    }
                    else
                    {
                        await context.Database.DeleteAsync();
                    }
                }
                else
                {
                    if (useEnsureMethod)
                    {
                        Assert.True(context.Database.EnsureDeleted());
                    }
                    else
                    {
                        context.Database.Delete();
                    }
                }

                // Exists still returns true because in-memory database is always available
                Assert.True(context.Database.Exists());
                Assert.True(await context.Database.ExistsAsync());

                Assert.Equal(0, await context.Fraggles.CountAsync());
            }

            using (var context = new FraggleContext())
            {
                Assert.Equal(0, await context.Fraggles.CountAsync());
            }
        }