Exemplo n.º 1
0
        public async void DeleteAsync_ShouldDeleteEmployee()
        {
            // Arrange
            var employeeToDelete = new Employee {
                Id = 1, FirstName = "John", LastName = "Dou", MediaInteractivaEmployee = true
            };

            var options = new DbContextOptionsBuilder <AppContext>()
                          .UseInMemoryDatabase(databaseName: "Employees5")
                          .Options;

            using (var appContext = new AppContext(options))
            {
                await appContext.Employees.AddAsync(employeeToDelete);

                await appContext.SaveChangesAsync();
            }

            using (var appContext = new AppContext(options))
            {
                var repo = new EmployeesRepository(appContext);

                // Act
                await repo.DeleteAsync(employeeToDelete.Id);


                // Assert
                var employee = appContext.Employees.Find(employeeToDelete.Id);
                Assert.Null(employee);
            }
        }