示例#1
0
        public void PatchAsync_overload5()
        {
            //Arrange
            RestInvoker target = new RestInvoker(_MyUri.OriginalString);
            StubModule.HaltProcessing = TimeSpan.FromSeconds(0);
            StubModule.PatchPerson = false;
            StubModule.TestHarness = new List<Person> { new Person { Id = 1, Email = "*****@*****.**" } };

            var body = new RestObjectRequestBody<Person>(new Person { Id = 1, Email = "*****@*****.**" });

            //Act
            target.PatchAsync("/Person/{id}", new { id = 1 }, body, ContentType.ApplicationX_WWW_Form_UrlEncoded).ContinueWith(task =>
            {
                using (RestResponse actual = task.Result)
                {
                    //Assert
                    Assert.True(StubModule.PatchPerson);
                    Assert.NotNull(actual);
                    Assert.True(actual.IsSuccessStatusCode);

                    var person = StubModule.TestHarness.Where(x => x.Id == 1).FirstOrDefault();
                    Assert.NotNull(person);
                    Assert.Equal("*****@*****.**", person.Email);
                }
            }).Wait();
        }