Exemplo n.º 1
0
        public void RemoveMappingThatDoesNotExistThrowsInvalidOperationException(
            ServiceErrorApiEvent apiEvent)
        {
            var addMappings = new Action <ExceptionHttpResponseConfiguration>(
                configuration =>
            {
                configuration.RemoveMapping <ServiceErrorApiEvent>();
            });

            Assert.Throws <InvalidOperationException>(
                () =>
            {
                var mapper = new TestApiEventHttpResponseMapper(addMappings);
                mapper.GetHttpResponse(null, apiEvent);
            });
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        public void DuplicateApiEventThrowsInvalidOperationException(
            ServiceErrorApiEvent apiEvent,
            ServiceErrorHttpResponse httpResponse)
        {
            var addMappings = new Action <ExceptionHttpResponseConfiguration>(
                configuration =>
            {
                configuration.AddMapping <ServiceErrorApiEvent>(
                    (e, c) => httpResponse);

                configuration.AddMapping <ServiceErrorApiEvent>(
                    (e, c) => httpResponse);
            });

            Assert.Throws <InvalidOperationException>(
                () =>
            {
                var mapper = new TestApiEventHttpResponseMapper(addMappings);
                mapper.GetHttpResponse(null, apiEvent);
            });
        }