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); }
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(); }
public EmployeesController(EmployeeManagementDbContext context, IWebHostEnvironment webHost, IFileManagerService fileManagerService, ILogger <EmployeesController> logger ) { _context = context; this.webHost = webHost; FileManagerService = fileManagerService; this._logger = logger; }
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); }
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; }
public UnitOfWork(EmployeeManagementDbContext context) { _context = context; AutoMapperConfig.Configure(); }
public DefaultLanguagesCreator(EmployeeManagementDbContext context) { _context = context; }
public Handler(EmployeeManagementDbContext dbContext, IDateTimeService dateTimeService) { _dbContext = dbContext; _dateTimeService = dateTimeService; }
public InitialHostDbBuilder(EmployeeManagementDbContext context) { _context = context; }
public EmployeesController() { dbcontext = new EmployeeManagementDbContext(); }
public DefaultSettingsCreator(EmployeeManagementDbContext context) { _context = context; }
public TenantRoleAndUserBuilder(EmployeeManagementDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
public DefaultTenantBuilder(EmployeeManagementDbContext context) { _context = context; }
public EmployeeProjectRepository(EmployeeManagementDbContext context) { _context = context; }
public HostRoleAndUserCreator(EmployeeManagementDbContext context) { _context = context; }
public Handler(EmployeeManagementDbContext dbContext) { _dbContext = dbContext; }
public EmployeeSkillRepository(EmployeeManagementDbContext context) { _context = context; }
public DepartmentsController() { dbcontext = new EmployeeManagementDbContext(); }