public void WhenPassingTransportAddressForPublisherInsteadOfEndpointName_UsingAssemblyAndNamespace_ShouldThrowException()
        {
            var routingSettings = new RoutingSettings<MessageDrivenTransportDefinition>(new SettingsHolder());

            var exception = Assert.Throws<ArgumentException>(() => routingSettings.RegisterPublisher(Assembly.GetExecutingAssembly(), nameof(EventNamespace), "EndpointName@MyHost"));
            Assert.AreEqual(expectedExceptionMessageForWrongEndpointName, exception.Message);
        }
        public void WhenPassingEndpointNameForPublisher_ShouldAddRouteToPublishers()
        {
            var routingSettings = new RoutingSettings<MessageDrivenTransportDefinition>(new SettingsHolder());
            routingSettings.RegisterPublisher(typeof(Event), "EndpointName");

            var publishers = ApplyPublisherRegistrations(routingSettings);

            var publishersForEvent = publishers.GetPublisherFor(typeof(Event)).SingleOrDefault();
            Assert.IsNotNull(publishersForEvent);
        }
        public void WhenPassingEndpointNameForPublisher_UsingAssemblyAndNamespace_ShouldAddEventsWithNamespaceToPublishers()
        {
            var routingSettings = new RoutingSettings<MessageDrivenTransportDefinition>(new SettingsHolder());
            routingSettings.RegisterPublisher(Assembly.GetExecutingAssembly(), nameof(EventNamespace), "EndpointName");

            var publishers = ApplyPublisherRegistrations(routingSettings);

            var publishersForEvent = publishers.GetPublisherFor(typeof(Event)).SingleOrDefault();
            var publishersForEventWithNamespace = publishers.GetPublisherFor(typeof(EventWithNamespace)).SingleOrDefault();

            Assert.IsNull(publishersForEvent);
            Assert.IsNotNull(publishersForEventWithNamespace);
        }
        public void Should_register_all_types_in_assembly_when_not_specifying_namespace()
        {
            var routingSettings = new RoutingSettings<MessageDrivenTransportDefinition>(new SettingsHolder());
            routingSettings.RegisterPublisher(Assembly.GetExecutingAssembly(), "someAddress");

            var publishers = ApplyPublisherRegistrations(routingSettings);

            var result1 = publishers.GetPublisherFor(typeof(BaseMessage)).SingleOrDefault();
            var result2 = publishers.GetPublisherFor(typeof(SubMessage)).SingleOrDefault();
            var result3 = publishers.GetPublisherFor(typeof(EventWithoutNamespace)).SingleOrDefault();
            var result4 = publishers.GetPublisherFor(typeof(IMessageInterface)).SingleOrDefault();

            Assert.IsNotNull(result1);
            Assert.IsNotNull(result2);
            Assert.IsNotNull(result3);
            Assert.IsNotNull(result4);
        }