예제 #1
0
        public async void FailDelete()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <AlpmysContext>()
                          .UseInMemoryDatabase("FailDeleteEvent")
                          .Options;
            AlpmysContext     context    = new AlpmysContext(options);
            EventosController controller = new EventosController(context);
            Evento            e          = new Evento();

            e.Nome = "Evento!";

            // Act
            await controller.PostEvento(e);

            var result = await controller.DeleteEvento(10);

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }
예제 #2
0
        public async void Delete()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <AlpmysContext>()
                          .UseInMemoryDatabase("DeleteEvent")
                          .Options;
            AlpmysContext     context    = new AlpmysContext(options);
            EventosController controller = new EventosController(context);
            Evento            e          = new Evento();

            e.Id   = 9;
            e.Nome = "Evento!";

            // Act
            await controller.PostEvento(e);

            await controller.DeleteEvento(9);

            // Assert
            Assert.Equal(0, context.Evento.Count());
        }