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); }); }
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); }
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); }
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); }
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); }); }