Exemplo n.º 1
0
        public void POST_Can_Add_Body_NoParams_Raw()
        {
            using( SimulatedServer.Create( AccessConstants.SimulatedServerUrl, Post_Body_Echo ) ) {

                SteamClient client = new SteamClient( AccessConstants.SimulatedServerUrl );
                var request = new SteamRequest( "/resource", HttpMethod.Post );
                request.DataFormat = PostDataFormat.Raw;

                string payload = "myContent 123 abc's fun!";

                request.AddBody( payload );

                var response = client.Execute( request );

                Assert.IsNotNull( response );
                Assert.IsNotNull( response.Content );
                Assert.AreEqual( payload, response.Content );

            }
        }
Exemplo n.º 2
0
        public void POST_Can_Add_Body_WithParams_Json()
        {
            using( SimulatedServer.Create( AccessConstants.SimulatedServerUrl, Post_Body_Echo ) ) {

                SteamClient client = new SteamClient( AccessConstants.SimulatedServerUrl );
                var request = new SteamRequest( "/resource", HttpMethod.Post );
                request.DataFormat = PostDataFormat.Json;

                request.AddBody( "myContent 123 abc's fun!" );

                request.AddParameter( "howdy", "doody" );
                request.AddParameter( "foo", "bar" );

                var response = client.Execute( request );

                Assert.IsNotNull( response );
                Assert.IsNotNull( response.Content );

                JObject obj = JObject.Parse( response.Content );

                Assert.AreEqual( "doody", obj["howdy"] );
                Assert.AreEqual( "bar", obj["foo"] );
                Assert.AreEqual( "myContent 123 abc's fun!", obj["application/json"] );

            }
        }
Exemplo n.º 3
0
        public void POST_Can_Add_DataStructure_Json()
        {
            using( SimulatedServer.Create( AccessConstants.SimulatedServerUrl, Post_Body_Echo ) ) {

                SteamClient client = new SteamClient( AccessConstants.SimulatedServerUrl );
                var request = new SteamRequest( "/resource", HttpMethod.Post );
                request.DataFormat = PostDataFormat.Json;

                object payload = new {
                    appids_filter = new int[] { 10, 20, 30, 40, 50 }
                };

                request.AddBody( payload );

                var response = client.Execute( request );

                Assert.IsNotNull( response );
                Assert.IsNotNull( response.Content );

                DataStructureResponseTest obj = JsonConvert.DeserializeObject<DataStructureResponseTest>( response.Content );

                Assert.AreEqual( 5, obj.appids_filter.Length );

            }
        }