public void Can_Resolve_MessageName_For_Unknown_Type()
 {
     var messageNamingService = new DefaultMessageNamingService();
     var messageName = messageNamingService.GetNameForType(typeof(ContractA));
     Assert.That(messageName, Is.Not.Null);
     Assert.That((string)messageName, Is.EqualTo("Platibus.UnitTests.DefaultMessageNamingServiceTests+ContractA"));
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new <see cref="PlatibusConfiguration"/> with a preconfigured
 /// <paramref name="diagnosticService"/> and an initial set of <paramref name="endpoints"/>
 /// </summary>
 /// <param name="diagnosticService">(Optional) The service through which diagnostic events
 /// are reported and processed</param>
 /// <param name="endpoints">(Optional) An initial set of default endpoints</param>
 /// <remarks>
 /// If a custom <paramref name="diagnosticService"/> is not specified, then the default
 /// singleton instance <see cref="Diagnostics.DiagnosticService.DefaultInstance"/> will
 /// be used.
 /// </remarks>
 public PlatibusConfiguration(IDiagnosticService diagnosticService, EndpointCollection endpoints)
 {
     MessageNamingService = new DefaultMessageNamingService();
     SerializationService = new DefaultSerializationService();
     DefaultContentType   = "application/json";
     DiagnosticService    = diagnosticService ?? Diagnostics.DiagnosticService.DefaultInstance;
     _endpoints           = endpoints ?? new EndpointCollection();
 }
        public void MessageNameCanBeResolvedForUnregisteredTypes()
        {
            var messageNamingService = new DefaultMessageNamingService();
            var messageName          = messageNamingService.GetNameForType(typeof(ContractA));

            Assert.NotNull(messageName);
            Assert.Equal("Platibus.UnitTests.DefaultMessageNamingServiceTests+ContractA", messageName);
        }
Esempio n. 4
0
        private static object DeserializeMessageContent(Message message)
        {
            var messageNamingService = new DefaultMessageNamingService();
            var serializationService = new DefaultSerializationService();

            var messageType = messageNamingService.GetTypeForName(message.Headers.MessageName);
            var serializer  = serializationService.GetSerializer(message.Headers.ContentType);

            return(serializer.Deserialize(message.Content, messageType));
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new <see cref="PlatibusConfiguration"/> instance with
 /// the default message naming and serialization services.
 /// </summary>
 /// <seealso cref="DefaultMessageNamingService"/>
 /// <seealso cref="DefaultSerializationService"/>
 public PlatibusConfiguration()
 {
     MessageNamingService = new DefaultMessageNamingService();
     SerializationService = new DefaultSerializationService();
 }