Beispiel #1
0
        public void Throws_Exception_When_Request_Has_Invalid_Json(string givenBody)
        {
            var httpRequest = PrepareHttpRequest(givenBody);

            var bodyStrategy = new JsonRequestBodyStrategy();

            bodyStrategy.Invoking(async _ => await _.ReadBodyAsJson(httpRequest.Object))
            .Should()
            .Throw <JsonReaderException>();
        }
Beispiel #2
0
        public void Can_Handle_Specific_ContentType(string givenContenType, bool expectedCanHandle)
        {
            var httpRequest = PrepareHttpRequest("{}", givenContenType);

            var bodyStrategy    = new JsonRequestBodyStrategy();
            var actualCanHandle = bodyStrategy.CanHandle(httpRequest.Object);

            actualCanHandle
            .Should()
            .Be(expectedCanHandle);
        }
Beispiel #3
0
        public async Task Attaches_Request_With_Json_Body_With_Type(
            string givenBody,
            string jsonPath,
            JTokenType expectedJsonType,
            string expectedJsonValue)
        {
            var httpRequest = PrepareHttpRequest(givenBody);

            var bodyStrategy     = new JsonRequestBodyStrategy();
            var actualBodyAsJson = await bodyStrategy.ReadBodyAsJson(httpRequest.Object);

            actualBodyAsJson.Type
            .Should()
            .Be(expectedJsonType);

            actualBodyAsJson.SelectToken(jsonPath).ToString()
            .Should()
            .Be(expectedJsonValue);
        }