public void GetUsersEmpty() { // Arrange iApiRepository stub = new ApiRepositoryStub(); var controller = new ApiSearchController(stub) { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; // Act var response = controller.Get("dofsdiofisdj"); var responseString = response.Content.ReadAsStringAsync().Result; dynamic results = JsonConvert.DeserializeObject <dynamic>(responseString); // Assert Assert.AreEqual("No user found", results); }
public void GetUsersContainsOK() { // Arrange iApiRepository stub = new ApiRepositoryStub(); var controller = new ApiSearchController(stub) { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; // Act var response = controller.Get("hule"); var responseString = response.Content.ReadAsStringAsync().Result; dynamic results = JsonConvert.DeserializeObject <dynamic>(responseString); // Assert Assert.AreEqual("100", (string)results[0].cristinID); Assert.AreEqual("Helga", (string)results[0].firstName); Assert.AreEqual("Bihule", (string)results[0].lastName); Assert.AreEqual("UiO", (string)results[0].institution); Assert.AreEqual("Konsulent", (string)results[0].position); }
public void GetUserStartsWithOK() { // Arrange iApiRepository stub = new ApiRepositoryStub(); var controller = new ApiSearchController(stub) { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; // Act var response = controller.Get("Peder"); var responseString = response.Content.ReadAsStringAsync().Result; dynamic results = JsonConvert.DeserializeObject <dynamic>(responseString); // Assert Assert.AreEqual("10", (string)results[0].cristinID); Assert.AreEqual("Peder", (string)results[0].firstName); Assert.AreEqual("Aasen", (string)results[0].lastName); Assert.AreEqual("OsloMet", (string)results[0].institution); Assert.AreEqual("Forskersjef", (string)results[0].position); }