public void GivenNamesWhenValuesAreSameShouldBeEquals() { var queueName1 = QueueName.Create("seedwork.cqrs"); var queueName2 = QueueName.Create("seedwork.cqrs"); queueName1.Should().Be(queueName2); }
public void GivenNameWhenSpaceAroundShouldTrim(string name, string expected) { var queueName = QueueName.Create(name); queueName.Should().NotBeNull(); queueName.Value.Should().Be(expected); }
public void GivenNameShouldCreate(string name) { var queueName = QueueName.Create(name); queueName.Should().NotBeNull(); queueName.Value.Should().Be(name); }
public void GivenNameWhenInvalidShouldThrowsArgumentException(string name) { Func <QueueName> action = () => QueueName.Create(name); action.Should().Throw <ArgumentException>(); }
public static async Task Main() { Console.Title = "KitchenConsole"; await new HostBuilder() .ConfigureAppConfiguration((hostContext, config) => { config.AddJsonFile("appsettings.json", optional: false); config.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true); config.AddEnvironmentVariables(); }) .ConfigureLogging(loggingBuilder => loggingBuilder.AddConsole()) .ConfigureServices((hostContext, services) => { var configuration = hostContext.Configuration; services.AddJustSaying(config => { config.Client(x => { if (configuration.HasAWSServiceUrl()) { // The AWS client SDK allows specifying a custom HTTP endpoint. // For testing purposes it is useful to specify a value that // points to a docker image such as `p4tin/goaws` or `localstack/localstack` x.WithServiceUri(configuration.GetAWSServiceUri()) .WithAnonymousCredentials(); } else { // The real AWS environment will require some means of authentication //x.WithBasicCredentials("###", "###"); //x.WithSessionCredentials("###", "###", "###"); } }); config.Messaging(x => { // Configures which AWS Region to operate in x.WithRegion(configuration.GetAWSRegion()); }); config.Subscriptions(x => { // Creates the following if they do not already exist // - a SQS queue of name `kitchenconsole-orderplacedevent` // - a SQS queue of name `kitchenconsole-orderplacedevent_error` // - a SNS topic of name `orderplacedevent` // - a SNS topic subscription on topic 'orderplacedevent' x.ForTopic <OrderPlacedEvent>(QueueName.Create <OrderPlacedEvent>(configuration)); // Add another subscription just to show that we can (subscribing to our own publish!) x.ForTopic <OrderReadyEvent>(QueueName.Create <OrderReadyEvent>(configuration)); }); config.Publications(x => { // Creates the following if they do not already exist // - a SNS topic of name `orderreadyevent` x.WithTopic <OrderReadyEvent>(); }); }); // Added a message handler for message type for 'OrderPlacedEvent' on topic 'orderplacedevent' services.AddJustSayingHandler <OrderPlacedEvent, OrderPlacedEventHandler>(); // Added another message handler for message type for 'OrderReadyEvent' on topic 'orderreadyevent' services.AddJustSayingHandler <OrderReadyEvent, OrderReadyEventHandler>(); // Add a background service that is listening for messages related to the above subscriptions services.AddHostedService <Subscriber>(); }) .UseConsoleLifetime() .Build() .RunAsync(); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers() .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddJustSaying(config => { config.Client(x => { if (_configuration.HasAWSServiceUrl()) { // The AWS client SDK allows specifying a custom HTTP endpoint. // For testing purposes it is useful to specify a value that // points to a docker image such as `p4tin/goaws` or `localstack/localstack` x.WithServiceUri(_configuration.GetAWSServiceUri()) .WithAnonymousCredentials(); } else { // The real AWS environment will require some means of authentication //x.WithBasicCredentials("###", "###"); //x.WithSessionCredentials("###", "###", "###"); } }); config.Messaging(x => { // Configures which AWS Region to operate in x.WithRegion(_configuration.GetAWSRegion()); }); config.Subscriptions(x => { // Creates the following if they do not already exist // - a SQS queue of name `orderingapi-orderreadyevent` // - a SQS queue of name `orderingapi-orderreadyevent_error` // - a SNS topic of name `orderreadyevent` // - a SNS topic subscription on topic 'orderreadyevent' x.ForTopic <OrderReadyEvent>(QueueName.Create <OrderReadyEvent>(_configuration)); // Add another subscription just to show that we can (subscribing to our own publish!) x.ForTopic <OrderPlacedEvent>(QueueName.Create <OrderPlacedEvent>(_configuration)); }); config.Publications(x => { // Creates the following if they do not already exist // - a SNS topic of name `orderplacedevent` x.WithTopic <OrderPlacedEvent>(); }); }); // Added a message handler for message type for 'OrderReadyEvent' on topic 'orderreadyevent' services.AddJustSayingHandler <OrderReadyEvent, OrderReadyEventHandler>(); // Added another message handler for message type for 'OrderPlacedEvent' on topic 'orderplacedevent' services.AddJustSayingHandler <OrderPlacedEvent, OrderPlacedEventHandler>(); // Add a background service that is listening for messages related to the above subscriptions services.AddHostedService <Subscriber>(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Restaurant Ordering API", Version = "v1" }); }); }