public void InvokeMethodWithGetRequest() { //Arrange RestInvoker target = new RestInvoker(); StubModule.HaltProcessing = TimeSpan.FromSeconds(0); StubModule.GetPerson = false; StubModule.TestHarness = new List<Person> { new Person { Id = 1, Email = "*****@*****.**" } }; RestRequest request = new RestRequest(HttpMethod.GET, new RestUri(_MyUri, "/Person/{id}").SetParameter("id", "1")); //Act using (RestResponse actual = target.Invoke(request)) { //Assert Assert.True(StubModule.GetPerson); Assert.True(actual.IsSuccessStatusCode); Assert.NotNull(actual); string content = actual.Body.ReadAsString(); Assert.Equal("{\"Id\":1,\"UID\":\"00000000-0000-0000-0000-000000000000\",\"Email\":\"[email protected]\",\"NoOfSiblings\":0,\"DOB\":\"\\/Date(-59011459200000)\\/\",\"IsActive\":false,\"Salary\":0}", content); } }
public void InvokeOfT_MethodWithGetRequest() { //Arrange RestInvoker target = new RestInvoker(); StubModule.HaltProcessing = TimeSpan.FromSeconds(0); StubModule.GetPerson = false; StubModule.TestHarness = new List<Person> { new Person { Id = 1, Email = "*****@*****.**" } }; RestRequest request = new RestRequest(HttpMethod.GET, new RestUri(_MyUri, "/Person/{id}").SetParameter("id", "1")); //Act using (RestResponse<Person> actual = target.Invoke<Person>(request)) { //Assert Assert.True(StubModule.GetPerson); Assert.NotNull(actual); Assert.NotNull(actual.Data); Assert.True(actual.IsSuccessStatusCode); Person person = actual.Data; Assert.Equal("*****@*****.**", person.Email); } }