Exemplo n.º 1
0
        public void Delete_NoData_ReturnsNull()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "NoGuides_Db_ForDelete")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                var service = new GuidesService(context);
                Assert.False(service.Delete(2));
            }
        }
Exemplo n.º 2
0
        public void Delete_WithData_DeletesGuide()
        {
            var options = new DbContextOptionsBuilder <GameInfoContext>()
                          .UseInMemoryDatabase(databaseName: "Db_WithGuides_ForDelete")
                          .Options;

            using (var context = new GameInfoContext(options))
            {
                context.Guides.Add(new Guide()
                {
                    Title = "ToDelete", Content = "None"
                });
                context.SaveChanges();
            }

            using (var context = new GameInfoContext(options))
            {
                var service = new GuidesService(context);
                var result  = service.Delete(1);

                Assert.True(result);
                Assert.Equal(0, context.Guides.Count());
            }
        }