Beispiel #1
0
        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)));
        }
Beispiel #2
0
        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)));
        }
Beispiel #3
0
        public void AddNewMappingGeneric()
        {
            var mappings = new HttpStatusCodeMappings();

            mappings.Add <ArgumentNullException>(400);

            Assert.Equal(400, mappings.GetStatusCode(typeof(ArgumentNullException)));
        }
Beispiel #4
0
        public void OverrideExistingGeneric()
        {
            var mappings = new HttpStatusCodeMappings();

            mappings.Add <NotFoundException>(500);

            Assert.Equal(500, mappings.GetStatusCode(typeof(NotFoundException)));
        }