예제 #1
0
        public void Count_ReturnsCorrectCount()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            using (var dbContext = new ApplicationDbContext(options))
            {
                Employee employee = new Employee()
                {
                    FirstName   = "Ivan",
                    MiddleName  = "Ivanov",
                    LastName    = "Ivanov",
                    PhoneNumber = "0897924218",
                    Email       = "*****@*****.**",
                    Town        = "Sofia",
                    Address     = "address 1",
                };

                dbContext.Employees.Add(employee);
                dbContext.SaveChanges();

                var employeesService = new EmployeesService(dbContext);
                int employeesCount   = employeesService.Count();

                Assert.Equal(1, employeesCount);
            }
        }