Ejemplo n.º 1
0
        public void GetSearchResultsOK()
        {
            // Arrange
            iApiRepository stub       = new ApiRepositoryStub();
            var            controller = new ApiSearchFullTextController(stub)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            // Act
            var     response       = controller.Get("lga");
            var     responseString = response.Content.ReadAsStringAsync().Result;
            dynamic results        = JsonConvert.DeserializeObject <dynamic>(responseString);

            // Assert
            Assert.AreEqual("10", (string)results[0].cristinID);
            Assert.AreEqual("Helga", (string)results[0].firstName);
            Assert.AreEqual("Aasen", (string)results[0].lastName);
            Assert.AreEqual("MEK", (string)results[0].affiliation.institute);
            Assert.AreEqual("OsloMet", (string)results[0].affiliation.institution);
            Assert.AreEqual("Forskersjef", (string)results[0].affiliation.position);

            Assert.AreEqual("100", (string)results[1].cristinID);
            Assert.AreEqual("Elgar", (string)results[1].firstName);
            Assert.AreEqual("Bihule", (string)results[1].lastName);
            Assert.AreEqual("TEK", (string)results[1].affiliation.institute);
            Assert.AreEqual("OsloMet", (string)results[1].affiliation.institution);
            Assert.AreEqual("Forskersjef", (string)results[1].affiliation.position);
        }
Ejemplo n.º 2
0
        public void GetSearchResultsEmpty()
        {
            // Arrange
            iApiRepository stub       = new ApiRepositoryStub();
            var            controller = new ApiSearchFullTextController(stub)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            // Act
            var     response       = controller.Get("sdfsdfspfs");
            var     responseString = response.Content.ReadAsStringAsync().Result;
            dynamic results        = JsonConvert.DeserializeObject <dynamic>(responseString);

            // Assert
            Assert.AreEqual("No user found", results);
        }