Ejemplo n.º 1
0
 public RetryTests()
 {
     _bus = CqrsBus
            .UseAssemblyFor <FakeLogger>()
            .AddRetry()
            .Build();
 }
Ejemplo n.º 2
0
        public LoggingTests()
        {
            var factory = new FakeLoggerFactory();

            _logger = factory.Logger;
            _bus    = CqrsBus
                      .UseAssemblyFor <FakeLogger>()
                      .AddLogging(factory)
                      .Build();
        }
Ejemplo n.º 3
0
        public async Task ShouldUseCommandsForAssemblyContainingType()
        {
            var bus = CqrsBus.UseAssemblyFor <FakeLogger>()
                      .Build();

            var args = new FakeCommandArgs();

            await bus.ExecuteAsync(args);

            Assert.True(args.DidExecute);
        }
Ejemplo n.º 4
0
        public async Task ShouldAllowUsageOfCustomRetryPolicy()
        {
            var bus = CqrsBus
                      .UseAssemblyFor <FakeLogger>()
                      .AddRetry(Policy.Handle <Exception>().RetryAsync(12))
                      .Build();

            var args = new FakeRetryCommandArgs(11);
            await bus.ExecuteAsync(args);

            Assert.Equal(12, args.TimesExecuted);
        }
Ejemplo n.º 5
0
        public DecorationTests()
        {
            FakeRetryFailuresEventHandler.TimesHandled = 0;

            var loggerFactory = new FakeLoggerFactory();

            _logger = loggerFactory.Logger;

            _bus = CqrsBus.UseAssemblyFor <FakeLogger>()
                   .AddLogging(loggerFactory)
                   .AddRetry()
                   .Build();
        }
Ejemplo n.º 6
0
        public async Task ShouldAllowExternalServicesToBeProvided()
        {
            var instance = new SomeService();
            var bus      = CqrsBus.UseAssemblyFor <FakeCommandWithServiceArgs>()
                           .AddSingleton <ISomeService>(instance)
                           .Build();

            var args = new FakeCommandWithServiceArgs();
            await bus.ExecuteAsync(args);

            Assert.Equal(instance, args.Service);
            Assert.True(args.DidExecute);
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            var services = new ServiceCollection().AddHttpClient();
            var bus      = CqrsBus
                           .UseAssemblyFor <Program>(services)
                           .Build();

            if (args.Length != 2)
            {
                System.Console.WriteLine("You must provide a command (get)");
            }

            if (args[0].ToLowerInvariant() == "get")
            {
                var content = bus.ExecuteAsync <string, string>(args[1]).Result;
                System.Console.WriteLine(content);
            }
        }
Ejemplo n.º 8
0
 public CqrsBusTests()
 {
     _bus = CqrsBus.UseAssemblyFor <FakeCommandArgs>()
            .UseAssemblyFor <FakeCommandThreeArgs>()
            .Build();
 }