Exemplo n.º 1
0
        public void PostGreetingTest()
        {
            var greetingName    = "newgreeting";
            var greetingMessage = "Hello Test";
            var fakeRequest     = new HttpRequestMessage(HttpMethod.Post, "http://localhost:9000/api/greeting");
            var greeting        = new Greeting()
            {
                Name = greetingName, Message = greetingMessage
            };
            var service = new GreetingController();

            service.Request = fakeRequest;
            var response = service.PostGreeting(greeting);

            Assert.IsNotNull(response);
            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.AreEqual(new Uri("http://localhost:9000/api/greeting/newgreeting"), response.Headers.Location);
        }
Exemplo n.º 2
0
        public void PostGreeting()
        {
            //arrange
            var name     = "greetingName";
            var message  = "greetingMessage";
            var greeting = new Greeting()
            {
                Name = name, Message = message
            };
            var fakeRequest = new HttpRequestMessage(HttpMethod.Post, new Uri("http://localhost:5581/api/greeting"));
            var service     = new GreetingController();

            service.Request = fakeRequest;
            // act
            var response = service.PostGreeting(greeting);

            //assert
            Assert.IsNotNull(response);
            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.AreEqual(new Uri("http://localhost:5581/api/greeting/greetingName"), response.Headers.Location);
        }