示例#1
0
        public void RestInvokerAddHeader_overload2()
        {
            //Arrange
            RestInvoker target = new RestInvoker(_MyUri.OriginalString);
            target.AddHeader(HttpRequestHeader.AcceptCharset, "utf-8");
            StubModule.Cookie = null;
            StubModule.HaltProcessing = TimeSpan.FromSeconds(0);
            StubModule.GetPerson = false;
            StubModule.TestHarness = new List<Person> { new Person { Id = 1, Email = "*****@*****.**" } };

            //Act
            using (RestResponse actual = target.Get("/Person/{id}", new { id = 1 }))
            {
                //Assert
                Assert.NotNull(StubModule.RequestHeaders);
                Assert.Equal("utf-8", StubModule.RequestHeaders["Accept-Charset"].FirstOrDefault());
            }

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

            //Act
            using (RestResponse actual = target.Get("/Person/{id}", new { id = 1 }))
            {
                //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);
            }
        }
示例#3
0
        public void RestInvokerAddCookie_overload2()
        {
            //Arrange
            RestInvoker target = new RestInvoker(_MyUri.OriginalString);
            target.AddCookie(new System.Net.Cookie("cookie1", "cookieValue1"));
            StubModule.Cookie = null;
            StubModule.HaltProcessing = TimeSpan.FromSeconds(0);
            StubModule.GetPerson = false;
            StubModule.TestHarness = new List<Person> { new Person { Id = 1, Email = "*****@*****.**" } };

            //Act
            using (RestResponse actual = target.Get("/Person/{id}", new { id = 1 }))
            {
                //Assert
                Assert.NotNull(StubModule.Cookie);
                Assert.Equal("cookieValue1", StubModule.Cookie["cookie1"]);
            }

        }