Esempio n. 1
0
        void AddEmployee()
        {
            var provider       = services.BuildServiceProvider();
            var cs             = "Server=.;Database=EMPSYSDB;Integrated Security=True;";
            var optionsBuilder = new DbContextOptionsBuilder <AppContext>();

            optionsBuilder.UseSqlServer(cs);

            var _ctx = new AppContext(optionsBuilder.Options);
            // Arrange
            Employee employee = GenerateOneEmployee();

            _ctx.Employees.Add(employee);

            // Act
            _ctx.SaveChanges();
            var DbEmployees = _ctx.Employees.ToList();

            // Assert
            Assert.Contains(employee, DbEmployees);
        }
Esempio n. 2
0
 public EmployeesController(AppContext context)
 {
     _unitOfWork = new UnitOfWork(context);
 }
Esempio n. 3
0
 public UnitOfWork(AppContext context)
 {
     _db = context;
 }