public List <Person> Get() { List <Person> persons = null; try { persons = personController.FindAll(); Response.StatusCode = 200; } catch (Exception ex) { Response.StatusCode = 500; Response.WriteAsync(ex.Message); } return(persons); }
public void FindAllReturnsListOfPerson() { //Arrange List <Person> personList = new List <Person> { new Person { Id = 1 }, new Person { Id = 2 } }; _personService.Setup(p => p.FindAll()).Returns(personList); //Act var controllerReturn = _personController.FindAll().Result as ObjectResult; var returnedList = controllerReturn.Value as List <Person>; //Assert Assert.AreEqual(200, controllerReturn.StatusCode.Value); Assert.AreEqual(2, returnedList.Count); }