public void If_a_messageForwarder_for_a_given_topic_does_not_exist_creates_it()
 {
     NotNullable<IMomRepository> momRepository = new NotNullable<IMomRepository>(Substitute.For<IMomRepository>()); 
     NotNullable<IServiceEvents> mediator = new ServiceEvents();
     NotNullable<IQuotaFactory> quotaFactory = new QuotaFactory(new HostConfiguration());
     var sut = new MessageForwarderFactory(momRepository, mediator, quotaFactory);
     Assert.NotNull(sut.CreateForwarder(StringExtension.RandomString()));
 }
Пример #2
0
 public void If_configuration_for_topic_exists_but_has_not_configured_any_quota_creates_a_transparentQuota()
 {
     var hostConfiguration = new HostConfiguration();
     hostConfiguration.Topics.Add(new TopicConfiguration
     {
         TopicName = "testTopic"
     });
     var sut = new QuotaFactory(hostConfiguration);
     Assert.IsType<TransparentQuota>(sut.CreateQuota("testTopic").Value);
 }
 public void If_a_messageForwarder_for_a_given_topic_already_exist_returns_that_instance()
 {
     NotNullable<IMomRepository> momRepository = new NotNullable<IMomRepository>(Substitute.For<IMomRepository>());
     NotNullable<IServiceEvents> mediator = new ServiceEvents();
     NotNullable<IQuotaFactory> quotaFactory = new QuotaFactory(new HostConfiguration());
     var sut = new MessageForwarderFactory(momRepository, mediator, quotaFactory);
     var topic = StringExtension.RandomString();
     var forwarder = sut.CreateForwarder(topic);
     Assert.Same(sut.CreateForwarder(topic), forwarder);
 }
Пример #4
0
 public void If_the_requested_topic_has_configured_a_quota_with_ElapsedMinutes_creates_an_ElapsedTimeQuota()
 {
     var hostConfiguration = new HostConfiguration();
     hostConfiguration.Topics.Add(new TopicConfiguration
     {
         TopicName = "testTopic",
         Quota = new QuotaConfiguration
         {
             ElapsedMinutes = 2
         }
     });
     var sut = new QuotaFactory(hostConfiguration);
     Assert.IsType<ElapsedTimeQuota>(sut.CreateQuota("testTopic").Value);
 }
Пример #5
0
 public void If_the_requested_topic_has_configured_a_quota_with_numberOfElements_creates_a_NumberOfElementsQuota()
 {
     var hostConfiguration = new HostConfiguration();
     hostConfiguration.Topics.Add(new TopicConfiguration
         {
             TopicName = "testTopic",
             Quota = new QuotaConfiguration
             {
                 NumberOfELements = 2
             }
         });
     var sut = new QuotaFactory(hostConfiguration);
     Assert.IsType<NumberOfElementsQuota>(sut.CreateQuota("testTopic").Value);
 }
Пример #6
0
 public void If_the_requested_topic_has_configured_a_quota_with_TimeRange_creates_an_TimeRangeQuota()
 {
     var hostConfiguration = new HostConfiguration();
     hostConfiguration.Topics.Add(new TopicConfiguration
     {
         TopicName = "testTopic",
         Quota = new QuotaConfiguration
         {
             TimeRange = new TimeRange
              {
                 From = new Time()
                 {
                     Hour = new Hour(10),
                     Minute = new Minute(3)
                 },
                 To = new Time()
                 {
                     Hour = new Hour(10),
                     Minute = new Minute(4)
                 }
             }
         }
     });
     var sut = new QuotaFactory(hostConfiguration);
     Assert.IsType<TimeRangeQuota>(sut.CreateQuota("testTopic").Value);
 }
Пример #7
0
 public void If_configuration_is_null_creates_a_transparentQuota()
 {
     var hostConfiguration = new HostConfiguration();
     var sut = new QuotaFactory(hostConfiguration);
     Assert.IsType<TransparentQuota>(sut.CreateQuota("testTopic").Value);
 }