public void GetByIdFail() { EmployeesController controller = new EmployeesController(new MockedEmployeeRepository(), new MockedCompanyService()); controller.Request = new HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); // Employee doesn't exist, should fail with 404 var response = controller.Get(3); Assert.IsFalse(response.IsSuccessStatusCode); Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); }
public void GetByIdSuccess() { EmployeesController controller = new EmployeesController(new MockedEmployeeRepository(), new MockedCompanyService()); controller.Request = new HttpRequestMessage(); controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); var response = controller.Get(2); EmployeeFullModel employee; Assert.IsTrue(response.IsSuccessStatusCode); Assert.IsTrue(response.TryGetContentValue<EmployeeFullModel>(out employee)); Assert.IsNotNull(employee); Assert.AreEqual(2, employee.EmployeeId); Assert.AreEqual("Test Company 2", employee.CompanyName); }