Exemplo n.º 1
0
        public void TestDelete()
        {
            //setting up pre-requisites <ARRANGE>
            var controller = new ServerDataController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            controller.Request.Headers.Add("refid", "123456");
            controller.Request.Headers.Add("Authorization", "Basic ZGhlZXJhajoxMjM0NTY=");

            //Act on Test <ACT>
            var response = controller.DELETE(1);

            //Assert the result <ASSERT>
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }
Exemplo n.º 2
0
        public void TestGetById()
        {
            //setting up pre-requisites <ARRANGE>
            var controller = new ServerDataController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            controller.Request.Headers.Add("refid", "123456");
            controller.Request.Headers.Add("Authorization", "Basic ZGhlZXJhajoxMjM0NTY=");

            //Act on Test <ACT>
            var response = controller.GET(1);

            //Assert the result <ASSERT>
            ServerInfo serverInfo;

            Assert.IsTrue(response.TryGetContentValue <ServerInfo>(out serverInfo));
            Assert.AreEqual(1, serverInfo.server_id);
        }
Exemplo n.º 3
0
        public void TestPost()
        {
            //setting up pre-requisites <ARRANGE>
            var controller = new ServerDataController();
            var serverData = new ServerInfo
            {
                server_id = 999,
                date      = "12-12-19",
                loction   = "pune",
                name      = "dheeraj"
            };

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            controller.Request.Headers.Add("refid", "123456");
            controller.Request.Headers.Add("Authorization", "Basic ZGhlZXJhajoxMjM0NTY=");

            //Act on Test <ACT>
            var response = controller.POST(serverData);

            //Assert the result <ASSERT>
            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
        }