Example #1
0
        public static void AddBus(Bus template, string srcDirectory, string testDirectory, string projectBaseName, string solutionDirectory, IFileSystem fileSystem)
        {
            var messagesDirectory = Path.Combine(solutionDirectory, "Messages");

            var massTransitPackages = new Dictionary <string, string> {
                { "MassTransit", "7.2.4" },
                { "MassTransit.AspNetCore", "7.2.4" },
                { "MassTransit.Extensions.DependencyInjection", "7.2.4" },
                { "MassTransit.RabbitMQ", "7.2.4" }
            };
            var webApiClassPath = ClassPathHelper.WebApiProjectClassPath(srcDirectory, projectBaseName);

            Utilities.AddPackages(webApiClassPath, massTransitPackages);

            WebApiServiceExtensionsBuilder.CreateMassTransitServiceExtension(srcDirectory, projectBaseName, fileSystem);
            foreach (var env in template.Environments)
            {
                WebApiAppSettingsModifier.AddRmq(srcDirectory, env, projectBaseName, fileSystem);
                StartupModifier.RegisterMassTransitService(srcDirectory, env.EnvironmentName, projectBaseName);
            }

            IntegrationTestFixtureModifier.AddMassTransit(testDirectory, projectBaseName);

            SolutionBuilder.BuildMessagesProject(solutionDirectory);

            Utilities.AddProjectReference(webApiClassPath, @"..\..\..\Messages\Messages.csproj");
        }
Example #2
0
        public static void AddConsumers(List <Consumer> consumers, string projectBaseName, string solutionDirectory, string srcDirectory, string testDirectory, IFileSystem fileSystem)
        {
            var validator = new ConsumerValidator();

            foreach (var consumer in consumers)
            {
                var results = validator.Validate(consumer);
                if (!results.IsValid)
                {
                    throw new DataValidationErrorException(results.Errors);
                }
            }

            consumers.ForEach(consumer =>
            {
                ConsumerBuilder.CreateConsumerFeature(solutionDirectory, srcDirectory, consumer, projectBaseName);
                ConsumerRegistrationBuilder.CreateConsumerRegistration(srcDirectory, consumer, projectBaseName);
                MassTransitModifier.AddConsumerRegistation(srcDirectory, consumer.EndpointRegistrationMethodName, projectBaseName);

                IntegrationTestFixtureModifier.AddMTConsumer(testDirectory, consumer.ConsumerName, consumer.DomainDirectory, projectBaseName, srcDirectory);
                ConsumerTestBuilder.CreateTests(solutionDirectory, testDirectory, srcDirectory, consumer, projectBaseName, fileSystem);
            });
        }