Inheritance: IPathFactory
Exemplo n.º 1
0
 public void WhenCreatingAQueue_WeShouldConvertToLowerCase()
 {
     var pathFactory = new PathFactory(new GlobalPrefixSetting());
     var path = pathFactory.TopicPathFor(typeof(MyEscapingTestMessages.EscapingTestMessage));
     var expectedName = "t." + typeof(MyEscapingTestMessages.EscapingTestMessage).FullName.Replace("+", ".").ToLower();
     path.ShouldBe(expectedName);
 }
Exemplo n.º 2
0
        private IEnumerable <string> CheckForDuplicateQueueNames()
        {
            var duplicateQueues = this.AllMessageContractTypes()
                                  .Select(t => new Tuple <string, Type>(PathFactory.QueuePathFor(t), t))
                                  .GroupBy(tuple => tuple.Item1)
                                  .Where(tuple => tuple.Count() > 1)
                                  .ToArray();

            var validationErrors = duplicateQueues
                                   .Select(tuple => "Some message types ({0}) would result in a duplicate queue name of {1}".FormatWith(string.Join(", ", tuple), tuple.Key))
                                   .ToArray();

            return(validationErrors);
        }
Exemplo n.º 3
0
        public void WhenCreatingAQueueForATypeWithAVeryLongName_WeShouldHaveAPathOfTheCorrectMaximumLength()
        {
            var prefix = new string('x', 230);
            var pathFactory = new PathFactory(new GlobalPrefixSetting {Value = prefix});
            var path = pathFactory.QueuePathFor(typeof(SimpleCommand));

            path.Length.ShouldBe(PathFactory.MaxPathLength);

            var expectedFullPath = $"{prefix}.q.nimbus.unittests.infrastructuretests.messagecontracts.simplecommand";
            var expectedShortenedPath = PathFactory.Shorten(expectedFullPath, PathFactory.MaxPathLength);
            path.ShouldBe(expectedShortenedPath);
        }
Exemplo n.º 4
0
 public void WhenCreatingANameForAMulticastSubscriptionWithAGlobalPrefix_ThePathShouldNotStartWithThePrefix()
 {
     var pathFactory = new PathFactory(new GlobalPrefixSetting {Value = "testprefix"});
     var subscriptionName = pathFactory.SubscriptionNameFor("My Application", "My Instance", typeof(SimpleEvent));
     subscriptionName.ShouldBe("my.application.my.instance.simpleevent");
 }
Exemplo n.º 5
0
 public void WhenCreatingAnInputQueuePathWithAGlobalPrefix_ThePathShouldStartWithThePrefix()
 {
     var pathFactory = new PathFactory(new GlobalPrefixSetting {Value = "testprefix"});
     var path = pathFactory.InputQueuePathFor("My Application", "My Instance");
     path.ShouldBe("testprefix.inputqueue.my.application.my.instance");
 }
Exemplo n.º 6
0
 public void WhenCreatingATopicPathWithAGlobalPrefix_ThePathShouldStartWithThePrefix()
 {
     var pathFactory = new PathFactory(new GlobalPrefixSetting {Value = "testprefix"});
     var path = pathFactory.TopicPathFor(typeof(SimpleEvent));
     path.ShouldBe("testprefix.t.nimbus.unittests.infrastructuretests.messagecontracts.simpleevent");
 }
Exemplo n.º 7
0
 public void WhenCreatingASubscriptionForATypeASpaceShouldBeConvertedToTheSanitizeCharacter()
 {
     var pathFactory = new PathFactory(new GlobalPrefixSetting());
     var subscriptionName = pathFactory.SubscriptionNameFor("My App", "App server", typeof(MyEventWithALongName));
     subscriptionName.ShouldBe("my.app.app.server.myeventwithalongname");
 }
Exemplo n.º 8
0
 public void WhenCreatingAQueueForAGenericType_WeShouldShortenTheGenericTypeArgumentName()
 {
     var pathFactory = new PathFactory(new GlobalPrefixSetting());
     var path = pathFactory.QueuePathFor(typeof(MyCommand<string>));
     path.ShouldBe("q.nimbus.unittests.infrastructuretests.messagecontracts.mycommand.1-string");
 }
Exemplo n.º 9
0
 public void WhenCreatingAQueueForAGenericType_WeShouldStripOutBackticks()
 {
     var pathFactory = new PathFactory(new GlobalPrefixSetting());
     var path = pathFactory.QueuePathFor(typeof(MyCommand<string>));
     path.ShouldNotContain("`");
 }
Exemplo n.º 10
0
 public void WhenCreatingASubscriptionForATypeWeHaveAMaximumLengthOf50()
 {
     var pathFactory = new PathFactory(new GlobalPrefixSetting());
     var path = pathFactory.SubscriptionNameFor("MyLongApplicationName", "Appserver", typeof(MyEventWithALongName));
     path.Length.ShouldBe(50);
 }
Exemplo n.º 11
0
        public void WhenCreatingADeadLetterQueueForATypeWithAVeryLongName_WeShouldHaveAPathOfTheCorrectMaximumLength()
        {
            var prefix = new string('x', 250);
            var pathFactory = new PathFactory(new GlobalPrefixSetting {Value = prefix});

            var path = pathFactory.DeadLetterOfficePath();

            path.Length.ShouldBe(PathFactory.MaxPathLength);

            var expectedFullPath = $"{prefix}.deadletteroffice";
            var expectedShortenedPath = PathFactory.Shorten(expectedFullPath, PathFactory.MaxPathLength);
            path.ShouldBe(expectedShortenedPath);
        }
Exemplo n.º 12
0
 public void WhenCreatingAQueueForANestedType_WeShouldStripOutPlusSigns()
 {
     var pathFactory = new PathFactory(new GlobalPrefixSetting());
     var path = pathFactory.TopicPathFor(typeof(MyEscapingTestMessages.EscapingTestMessage));
     path.ShouldNotContain("+");
 }
        private IEnumerable<string> CheckForDuplicateQueueNames()
        {
            var pathFactory = new PathFactory(new GlobalPrefixSetting());
            var duplicateQueues = this.AllMessageContractTypes()
                                      .Select(t => new Tuple<string, Type>(pathFactory.QueuePathFor(t), t))
                                      .GroupBy(tuple => tuple.Item1)
                                      .Where(tuple => tuple.Count() > 1)
                                      .ToArray();

            var validationErrors = duplicateQueues
                .Select(tuple => "Some message types ({0}) would result in a duplicate queue name of {1}".FormatWith(string.Join(", ", tuple), tuple.Key))
                .ToArray();

            return validationErrors;
        }