예제 #1
0
        public static EchoModel CreateEcho()
        {
            EchoModel model = new EchoModel();

            Console.WriteLine("Input echo msg to server: ");
            model.Message = Console.ReadLine();

            return(model);
        }
예제 #2
0
        public void Should_be_able_to_send_json_in_body()
        {
            // Given
            var model = new EchoModel { SomeString = "Some String", SomeInt = 29, SomeBoolean = true };

            // When
            var result = browser.Post("/", with =>
                                            {
                                                with.JsonBody(model);
                                            });

            // Then
            var actualModel = result.Body.DeserializeJson<EchoModel>();

            actualModel.ShouldNotBeNull();
            actualModel.SomeString.ShouldEqual(model.SomeString);
            actualModel.SomeInt.ShouldEqual(model.SomeInt);
            actualModel.SomeBoolean.ShouldEqual(model.SomeBoolean);
        }
예제 #3
0
        public async Task Should_be_able_to_send_xml_in_body()
        {
            // Given
            var model = new EchoModel {
                SomeString = "Some String", SomeInt = 29, SomeBoolean = true
            };

            // When
            var result = await browser.Post("/", with =>
            {
                with.XMLBody(model);
            });

            // Then
            var actualModel = result.Body.DeserializeXml <EchoModel>();

            actualModel.ShouldNotBeNull();
            actualModel.SomeString.ShouldEqual(model.SomeString);
            actualModel.SomeInt.ShouldEqual(model.SomeInt);
            actualModel.SomeBoolean.ShouldEqual(model.SomeBoolean);
        }
예제 #4
0
        public void Should_be_able_to_send_xml_in_body()
        {
            // Given
            var model = new EchoModel { SomeString = "Some String", SomeInt = 29, SomeBoolean = true };

            // When
            var result = browser.Post("/", with =>
                {
                    with.XMLBody(model);
                });

            // Then
            var actualModel = result.Body.DeserializeXml<EchoModel>();

            actualModel.ShouldNotBeNull();
            actualModel.SomeString.ShouldEqual(model.SomeString);
            actualModel.SomeInt.ShouldEqual(model.SomeInt);
            actualModel.SomeBoolean.ShouldEqual(model.SomeBoolean);
        }
 public string Echo([FromBody] EchoModel echoModel)
 {
     return($"ECHO: {echoModel.EchoText}");
 }
예제 #6
0
파일: BrowserFixture.cs 프로젝트: l3m/Nancy
        public async Task Should_be_able_to_send_json_in_body()
        {
            // Given
            var model = new EchoModel { SomeString = "Some String", SomeInt = 29, SomeBoolean = true };

            // When
            var result = await browser.Post("/", with =>
                {
                    with.JsonBody(model);
                });

            // Then
            var actualModel = result.Body.DeserializeJson<EchoModel>();

            actualModel.ShouldNotBeNull();
            actualModel.SomeString.ShouldEqual(model.SomeString);
            actualModel.SomeInt.ShouldEqual(model.SomeInt);
            actualModel.SomeBoolean.ShouldEqual(model.SomeBoolean);
        }