public static IMayWantOptionalSettings InRegions(this JustSayingFluentlyDependencies dependencies, IEnumerable <string> regions) { var config = new MessagingConfig(); if (dependencies.MessageSubjectProvider != null) { config.MessageSubjectProvider = dependencies.MessageSubjectProvider; } if (regions != null) { foreach (var region in regions) { config.Regions.Add(region); } } config.Validate(); var messageSerializationRegister = new MessageSerializationRegister(config.MessageSubjectProvider); var justSayingBus = new JustSayingBus(config, messageSerializationRegister, dependencies.LoggerFactory); var awsClientFactoryProxy = new AwsClientFactoryProxy(() => CreateMeABus.DefaultClientFactory()); var amazonQueueCreator = new AmazonQueueCreator(awsClientFactoryProxy, dependencies.LoggerFactory); var bus = new JustSayingFluently(justSayingBus, amazonQueueCreator, awsClientFactoryProxy, dependencies.LoggerFactory); bus .WithMonitoring(new NullOpMessageMonitor()) .WithSerializationFactory(new NewtonsoftSerializationFactory()); return(bus); }
public async Task Arn_Still_Retrieved_When_It_Already_Exists() { // Arrange string topicName = Guid.NewGuid().ToString(); ILoggerFactory loggerFactory = OutputHelper.ToLoggerFactory(); var subjectProvider = new NonGenericMessageSubjectProvider(); var serializerFactor = new NewtonsoftSerializationFactory(); var serializationRegister = new MessageSerializationRegister(subjectProvider, serializerFactor); IAmazonSimpleNotificationService client = CreateSnsClient(exists: true); var topic = new SnsTopicByName( topicName, client, serializationRegister, loggerFactory, subjectProvider); // Act await topic.CreateAsync(); // Assert topic.Arn.ShouldNotBeNull(); }
public async Task Then_An_Exception_Is_Not_Thrown() { // Arrange string topicName = Guid.NewGuid().ToString(); ILoggerFactory loggerFactory = OutputHelper.ToLoggerFactory(); IAwsClientFactory clientFactory = CreateClientFactory(); var subjectProvider = new NonGenericMessageSubjectProvider(); var serializationRegister = new MessageSerializationRegister(subjectProvider); var client = clientFactory.GetSnsClient(Region); var topic = new SnsTopicByName( topicName, client, serializationRegister, loggerFactory, subjectProvider); // Act and Assert (await topic.CreateAsync()).ShouldBeTrue(); (await topic.CreateAsync()).ShouldBeTrue(); topic.Arn.ShouldNotBeNull(); topic.Arn.ShouldEndWith(topic.TopicName); }
public async Task Cannot_Create_Topic_Because_It_Exists() { // Arrange string topicName = Guid.NewGuid().ToString(); ILoggerFactory loggerFactory = OutputHelper.ToLoggerFactory(); var subjectProvider = new NonGenericMessageSubjectProvider(); var serializerFactor = new NewtonsoftSerializationFactory(); var serializationRegister = new MessageSerializationRegister(subjectProvider, serializerFactor); IAmazonSimpleNotificationService client = CreateSnsClient(exists: true); var topic = new SnsTopicByName( topicName, client, serializationRegister, loggerFactory, subjectProvider); // Act bool actual = await topic.CreateAsync(); // Assert actual.ShouldBeFalse(); topic.Arn.ShouldNotBeNull(); }
private JustSaying.JustSayingBus CreateBus() { var config = Substitute.For <IMessagingConfig>(); var serializationRegister = new MessageSerializationRegister( new NonGenericMessageSubjectProvider(), new NewtonsoftSerializationFactory()); var bus = new JustSaying.JustSayingBus(config, serializationRegister, LoggerFactory, MessageMonitor); var defaultSubscriptionSettings = new SubscriptionGroupSettingsBuilder() .WithDefaultMultiplexerCapacity(1) .WithDefaultPrefetch(1) .WithDefaultBufferSize(1) .WithDefaultConcurrencyLimit(1); bus.SetGroupSettings(defaultSubscriptionSettings, new Dictionary <string, SubscriptionGroupConfigBuilder>()); return(bus); }
public async Task Cannot_Create_Topic_Because_Not_Authorized() { // Arrange string topicName = Guid.NewGuid().ToString(); ILoggerFactory loggerFactory = OutputHelper.ToLoggerFactory(); var subjectProvider = new NonGenericMessageSubjectProvider(); var serializationRegister = new MessageSerializationRegister(subjectProvider); IAmazonSimpleNotificationService client = CreateSnsClient(exists: false); var topic = new SnsTopicByName( topicName, client, serializationRegister, loggerFactory, subjectProvider); // Act and Assert await Assert.ThrowsAsync <InvalidOperationException>(() => topic.CreateAsync()); }