Example #1
0
 public void CustomMap()
 {
     const String contentType = "application/dummy";
     var configuration = new SerializationConfiguration();
     configuration.Map(header => header.MediaType == contentType, new FakeSerializer());
     var serializer = configuration.Create(contentType);
     Assert.IsType<FakeSerializer>(serializer);
 }
Example #2
0
 public void CustomNegotiation()
 {
     const String contentType = "application/custom";
     var configuration = new SerializationConfiguration();
     configuration.Map(_ => _.MediaType == "application/custom", new FakeSerializer());
     var negotiator = new Mock<IContentNegotiator>();
     var @set = new SortedSet<ContentNegotiator.MediaTypeHeader>();
     @set.Add(ContentNegotiator.MediaTypeHeader.Parse(contentType));
     negotiator.Setup(_ => _.Negotiate(contentType))
               .Returns(@set);
     configuration.NegotiateBy(negotiator.Object);
     var serializer = configuration.Create(contentType);
     Assert.IsType<FakeSerializer>(serializer);
 }