public async Task HandleAsync_InputIsNormalCommand_ShouldRecordHistory()
        {
            var database = new EmployeeManagementDbContext(Guid.NewGuid().ToString());

            database.Add(new DomainModel.Entities.Employee()
            {
                EmployeeId = Guid.Empty,
                Name       = "TestName",
                Position   = "TestPosition"
            });
            await database.SaveChangesAsync();

            var handler     = new Application.Employee.UpdateEmployee.Handler(database, GetDateTimeServiceMock());
            var newName     = "NewTestName";
            var newPosition = "NewTestPosition";
            var command     = new Application.Employee.UpdateEmployee.Command()
            {
                EmployeeId = Guid.Empty,
                Employee   = new DomainModel.Entities.Employee()
                {
                    Name     = newName,
                    Position = newPosition
                }
            };

            await handler.Handle(command, CancellationToken.None);

            var result  = database.Employees.FirstOrDefault(e => e.EmployeeId == Guid.Empty);
            var history = result.EditHistories[0];

            Assert.AreEqual(DateTime.MinValue, history.TimeStamp);
            Assert.AreEqual(newName, history.Name);
            Assert.AreEqual(newPosition, history.Position);
        }
        public async Task HandleAsync_InputIsNormalQuery_ShouldReturnProperEmployee()
        {
            var database = new EmployeeManagementDbContext(Guid.NewGuid().ToString());

            database.Add(new DomainModel.Entities.Employee()
            {
                EmployeeId = Guid.Parse("00000000-0000-0000-0000-000000000000"),
                Name       = "TestName1",
                Position   = "TestPosition1",
            });
            database.Add(new DomainModel.Entities.Employee()
            {
                EmployeeId = Guid.Parse("00000000-0000-0000-0000-000000000001"),
                Name       = "TestName2",
                Position   = "TestPosition2",
            });
            await database.SaveChangesAsync();

            var handler = new Application.Employee.ReadEmployeeById.Handler(database);
            var query   = new Application.Employee.ReadEmployeeById.Query()
            {
                EmployeeId = Guid.Parse("00000000-0000-0000-0000-000000000001")
            };

            var result = await handler.Handle(query, CancellationToken.None);

            Assert.AreEqual(Guid.Parse("00000000-0000-0000-0000-000000000001"), result.EmployeeId);
        }
Esempio n. 3
0
        public static void SeedHostDb(EmployeeManagementDbContext context)
        {
            context.SuppressAutoSetTenantId = true;

            // Host seed
            new InitialHostDbBuilder(context).Create();

            // Default tenant seed (in host database).
            new DefaultTenantBuilder(context).Create();
            new TenantRoleAndUserBuilder(context, 1).Create();
        }
Esempio n. 4
0
 public EmployeesController(EmployeeManagementDbContext context,
                            IWebHostEnvironment webHost,
                            IFileManagerService fileManagerService,
                            ILogger <EmployeesController> logger
                            )
 {
     _context           = context;
     this.webHost       = webHost;
     FileManagerService = fileManagerService;
     this._logger       = logger;
 }
Esempio n. 5
0
        public async Task HandleAsync_InputIsCreateCommand_ShouldSaveToDatabase()
        {
            var database = new EmployeeManagementDbContext(Guid.NewGuid().ToString());
            var handler  = new Application.Employee.CreateEmployee.Handler(database, GetDateTimeServiceMock());
            var command  = new Application.Employee.CreateEmployee.Command()
            {
                Employee = new DomainModel.Entities.Employee()
                {
                    Name     = "TestName",
                    Position = "TestPosition"
                }
            };

            await handler.Handle(command, CancellationToken.None);

            var result = await database.Employees.FirstOrDefaultAsync(
                employee => employee.Name == "TestName" && employee.Position == "TestPosition");

            Assert.NotNull(result);
        }
Esempio n. 6
0
        public async Task HandleAsync_InputIsNormalData_ShouldDeletFromDatabase()
        {
            var database = new EmployeeManagementDbContext(Guid.NewGuid().ToString());

            database.Employees.Add(new DomainModel.Entities.Employee()
            {
                EmployeeId = Guid.Empty,
                Name       = "TestName",
                Position   = "TestPosition"
            });
            await database.SaveChangesAsync();

            var handler = new Application.Employee.DeleteEmployee.Handler(database);
            var command = new Application.Employee.DeleteEmployee.Command()
            {
                EmployeeId = Guid.Empty
            };

            await handler.Handle(command, CancellationToken.None);

            Assert.AreEqual(0, database.Employees.Count());
        }
 public DefaultEditionCreator(EmployeeManagementDbContext context)
 {
     _context = context;
 }
Esempio n. 8
0
 public UnitOfWork(EmployeeManagementDbContext context)
 {
     _context = context;
     AutoMapperConfig.Configure();
 }
Esempio n. 9
0
 public DefaultLanguagesCreator(EmployeeManagementDbContext context)
 {
     _context = context;
 }
Esempio n. 10
0
 public Handler(EmployeeManagementDbContext dbContext, IDateTimeService dateTimeService)
 {
     _dbContext       = dbContext;
     _dateTimeService = dateTimeService;
 }
Esempio n. 11
0
 public InitialHostDbBuilder(EmployeeManagementDbContext context)
 {
     _context = context;
 }
Esempio n. 12
0
 public EmployeesController()
 {
     dbcontext = new EmployeeManagementDbContext();
 }
Esempio n. 13
0
 public DefaultSettingsCreator(EmployeeManagementDbContext context)
 {
     _context = context;
 }
Esempio n. 14
0
 public TenantRoleAndUserBuilder(EmployeeManagementDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
 public DefaultTenantBuilder(EmployeeManagementDbContext context)
 {
     _context = context;
 }
Esempio n. 16
0
 public EmployeeProjectRepository(EmployeeManagementDbContext context)
 {
     _context = context;
 }
 public HostRoleAndUserCreator(EmployeeManagementDbContext context)
 {
     _context = context;
 }
Esempio n. 18
0
 public Handler(EmployeeManagementDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Esempio n. 19
0
 public EmployeeSkillRepository(EmployeeManagementDbContext context)
 {
     _context = context;
 }
Esempio n. 20
0
 public DepartmentsController()
 {
     dbcontext = new EmployeeManagementDbContext();
 }