public async Task CreateEmployee_NameNotSpecified_Fail() { var dto = new CreateEmployeeDTO(); await using var dbContext = GetDbContext(); var service = new EmployeesService(dbContext); var result = await service.CreateEmployee(dto); Assert.IsTrue(result.IsFailure); }
public async Task CreateEmployee_NameSpecified_ContactsEmpty_Success() { var dto = new CreateEmployeeDTO { Name = "name" }; await using var dbContext = GetDbContext(); var service = new EmployeesService(dbContext); var result = await service.CreateEmployee(dto); Assert.IsTrue(result.IsSuccess); }
public HttpResponseMessage CreateEmployee(HttpRequestMessage request) { EmployeesService employees = new EmployeesService(); // return request.CreateResponse(HttpStatusCode.OK, employees.CreateEmployee(_id_employee, _name_employee, _id_office, _position)); try { employees.CreateEmployee(_id_employee, _name_employee, _id_office, _position); return(request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(request.CreateResponse(HttpStatusCode.BadRequest, ex.ToString())); } }
public async Task CreateEmployee_InvalidContacts_Fail() { var dto = new CreateEmployeeDTO { Name = "name", Contacts = new List <ContactDTO> { new ContactDTO { Type = ContactType.Email } } }; await using var dbContext = GetDbContext(); var service = new EmployeesService(dbContext); var result = await service.CreateEmployee(dto); Assert.IsTrue(result.IsFailure); }