public void TestAllDeleteMethods()
        {
            var sever     = TestFactory.GetServerAndStart();
            var response1 = RequestActivator.SendRequest(RequestType.DELETE, "testcontroller/", null, "").Result;

            Assert.Equal("Name was removed", response1 as string);
            var response2 = RequestActivator.SendRequest(RequestType.DELETE, "testcontroller/WithRoute", null, "").Result;

            Assert.Equal("Name was removed: With Route", response2 as string);
            var response3 = RequestActivator.SendRequest(RequestType.DELETE, "testcontroller/MyName", null, "").Result;

            Assert.Equal("MyName was removed: With Parameter", response3 as string);
        }
Beispiel #2
0
        public void TestAllPutMethods()
        {
            var sever   = TestFactory.GetServerAndStart();
            var bodyObj = new InputDataForPostMethod
            {
                Name = "Weber",
                Age  = 35
            };
            var data      = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObj));
            var response1 = RequestActivator.SendRequest(RequestType.PUT, "testcontroller/", new byte[] {}, "").Result;

            Assert.Equal("Put is Ok!", response1 as string);
            var response2 = RequestActivator.SendRequest(RequestType.PUT, "testcontroller/WithRoute", data, "").Result;

            Assert.Equal($"Put the name: {bodyObj.Name}", response2 as string);
        }
Beispiel #3
0
        public void TestAllGetMethods()
        {
            var sever     = TestFactory.GetServerAndStart();
            var response1 = RequestActivator.SendRequest(RequestType.GET, "testcontroller/", null, "").Result;

            Assert.Equal("Hello world", response1 as string);
            var response2 = RequestActivator.SendRequest(RequestType.GET, "testcontroller/WithNumber?number=123", null, "").Result;

            Assert.Equal("Result: 124", response2 as string);
            var response3 = RequestActivator.SendRequest(RequestType.GET, "testcontroller/camelCaseRoute", null, "").Result;

            Assert.Equal("It's Route With camel case", response3 as string);
            var response4 = RequestActivator.SendRequest(RequestType.GET, "testcontroller/67890?queryParameter=012345", null, "").Result;

            Assert.Equal("Result: 01234567890", response4 as string);
        }
        public void TestAllPostMethods()
        {
            var sever   = TestFactory.GetServerAndStart();
            var bodyObj = new InputDataForPostMethod
            {
                Name = "Weber",
                Age  = 35
            };
            var data      = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObj));
            var response1 = RequestActivator.SendRequest(RequestType.POST, "testcontroller/", data, "").Result;

            Assert.Equal($"My name is {bodyObj.Name} and i {bodyObj.Age} years old", response1 as string);
            var response2 = RequestActivator.SendRequest(RequestType.POST, "testcontroller/WithRoute", data, "").Result;

            Assert.Equal($"My name is {bodyObj.Name} and i {bodyObj.Age} years old and I love methods with routes", response2 as string);
        }