public void InitializeDefaults() { var mappings = new HttpStatusCodeMappings(); Assert.Equal(404, mappings.GetStatusCode(typeof(NotFoundException))); Assert.Equal(400, mappings.GetStatusCode(typeof(ValidationException))); Assert.Equal(403, mappings.GetStatusCode(typeof(UnauthorizedException))); }
public void AddNewMappingsRange() { var newRange = new Dictionary <Type, int>() { { typeof(ArgumentNullException), 400 }, { typeof(InvalidOperationException), 500 } }; var mappings = new HttpStatusCodeMappings(); mappings.AddRange(newRange); Assert.Equal(400, mappings.GetStatusCode(typeof(ArgumentNullException))); Assert.Equal(500, mappings.GetStatusCode(typeof(InvalidOperationException))); }
public void AddNewMappingGeneric() { var mappings = new HttpStatusCodeMappings(); mappings.Add <ArgumentNullException>(400); Assert.Equal(400, mappings.GetStatusCode(typeof(ArgumentNullException))); }
public void OverrideExistingGeneric() { var mappings = new HttpStatusCodeMappings(); mappings.Add <NotFoundException>(500); Assert.Equal(500, mappings.GetStatusCode(typeof(NotFoundException))); }