public void GetSerializer()
 {
     var factories = new List<IExportFactory<ISerializer, SerializerMetadata>>();
     factories.Add(this.GetSerializerFactory(typeof(JsonFormat)));
     var serializationService = new DefaultSerializationService(factories);
     var serializer = serializationService.GetSerializer();
     Assert.IsNotNull(serializer);
 }
 public void GetSerializer_WithOverride()
 {
     var factories = new List<IExportFactory<ISerializer, SerializerMetadata>>();
     var oldSerializer = Mock.Create<ISerializer>();
     var newSerializer = Mock.Create<ISerializer>();
     factories.Add(this.GetSerializerFactory(typeof(JsonFormat), oldSerializer, Priority.Normal));
     factories.Add(this.GetSerializerFactory(typeof(JsonFormat), newSerializer, Priority.AboveNormal));
     var serializationService = new DefaultSerializationService(factories);
     var serializer = serializationService.GetSerializer();
     Assert.AreSame(serializer, newSerializer);
 }
 public void GetSerializer_NoContext_Exception()
 {
     var serializationService = new DefaultSerializationService(new List<IExportFactory<ISerializer, SerializerMetadata>>());
     Assert.Throws<KeyNotFoundException>(() => serializationService.GetSerializer());
 }
 public void GetSerializer_WithContext_Exception(Type formatType)
 {
     var serializationService = new DefaultSerializationService(new List<IExportFactory<ISerializer, SerializerMetadata>>());
     var context = new SerializationContext(formatType);
     Assert.Throws<KeyNotFoundException>(() => serializationService.GetSerializer(context));
 }