Beispiel #1
0
        public void AddMappingGetResponseReturnsExpectedResponse(
            ServiceErrorApiEvent apiEvent,
            ServiceErrorHttpResponse httpResponse)
        {
            var addMappings = new Action <ExceptionHttpResponseConfiguration>(
                configuration =>
            {
                configuration.AddMapping <ServiceErrorApiEvent>(
                    (e, c) => httpResponse);
            });

            var mapper   = new TestApiEventHttpResponseMapper(addMappings);
            var response = mapper.GetHttpResponse(null, apiEvent);

            Assert.Equal(httpResponse, response);
        }
Beispiel #2
0
        public void UpdateMappingThatDoesNotExistThrowsInvalidOperationException(
            ServiceErrorApiEvent apiEvent,
            ServiceErrorHttpResponse httpResponse)
        {
            var addMappings = new Action <ExceptionHttpResponseConfiguration>(
                configuration =>
            {
                configuration.UpdateMapping <ServiceErrorApiEvent>(
                    (e, c) => httpResponse);
            });

            Assert.Throws <InvalidOperationException>(
                () =>
            {
                var mapper = new TestApiEventHttpResponseMapper(addMappings);
                mapper.GetHttpResponse(null, apiEvent);
            });
        }
Beispiel #3
0
        public void RemoveMappingRemovesTheMapping(
            ServiceErrorApiEvent apiEvent,
            ServiceErrorHttpResponse httpResponse)
        {
            var addMappings = new Action <ExceptionHttpResponseConfiguration>(
                configuration =>
            {
                configuration.AddMapping <ServiceErrorApiEvent>(
                    (e, c) => httpResponse);

                configuration.RemoveMapping <ServiceErrorApiEvent>();
            });

            var mapper   = new TestApiEventHttpResponseMapper(addMappings);
            var response = mapper.GetHttpResponse(null, apiEvent);

            Assert.Null(response);
        }
Beispiel #4
0
        public void UpdateMappingUpdatesTheResponse(
            ServiceErrorApiEvent apiEvent,
            ServiceErrorHttpResponse httpResponse,
            ServiceErrorHttpResponse httpResponseReplacement)
        {
            var addMappings = new Action <ExceptionHttpResponseConfiguration>(
                configuration =>
            {
                configuration.AddMapping <ServiceErrorApiEvent>(
                    (e, c) => httpResponse);

                configuration.UpdateMapping <ServiceErrorApiEvent>(
                    (e, c) => httpResponseReplacement);
            });

            var mapper   = new TestApiEventHttpResponseMapper(addMappings);
            var response = mapper.GetHttpResponse(null, apiEvent);

            Assert.Equal(httpResponseReplacement, response);
        }