예제 #1
0
        public void Exception_thrown_for_invalid_mapper()
        {
            var mediaTypeMapper = new MediaTypeMapper.Builder().Build();

            Assert.Throws <MediaTypeNotSupportedException>(() =>
                                                           mediaTypeMapper.From(new object(), ContentMediaType.Json));
        }
예제 #2
0
        public void Parameters_do_not_affect_mapping()
        {
            var mediaTypeMapper = new MediaTypeMapper.Builder()
                                  .AddMapperFor(ContentMediaType.Json, DefaultJsonMapper.Instance)
                                  .Build();
            var contentMediaType = ContentMediaType.ParseFromDescriptor("application/json; charset=UTF-8");

            mediaTypeMapper.From(new object(), contentMediaType);
        }
예제 #3
0
        public void Registered_mapper_maps_type()
        {
            var mappedToObject = new Object();
            var mappedToString = "mappedToString";

            var testMapper      = new TestMapper <object>(mappedToObject, mappedToString);
            var mediaTypeMapper = new MediaTypeMapper.Builder()
                                  .AddMapperFor(ContentMediaType.Json, testMapper)
                                  .Build();

            Assert.Equal(mappedToString, mediaTypeMapper.From(new object(), ContentMediaType.Json));
        }