public void InvokeAsyncMethodWithGetRequest() { //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 target.InvokeAsync(request).ContinueWith(task => { using (var actual = task.Result) { //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); } }).Wait(); }
public void InvokeAsyncOfT_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 target.InvokeAsync<Person>(request).ContinueWith(task => { using (RestResponse<Person> actual = task.Result) { //Assert Assert.True(StubModule.GetPerson); Assert.NotNull(actual); Assert.NotNull(actual.Data); Assert.True(actual.IsSuccessStatusCode); Person person = actual.Data; Assert.Equal("*****@*****.**", person.Email); } }).Wait(); }