예제 #1
0
 public static IScenarioWithEndpointBehavior <TContext> WithRouter <TContext>(this IScenarioWithEndpointBehavior <TContext> scenario, string name, Action <RouterConfiguration> configCallback)
     where TContext : ScenarioContext
 {
     return(scenario.WithComponent(new RouterComponent(s =>
     {
         var cfg = new RouterConfiguration(name);
         configCallback(cfg);
         return cfg;
     })));
 }
예제 #2
0
 public static IScenarioWithEndpointBehavior <TContext> With <TContext, TLeft, TRight>(this IScenarioWithEndpointBehavior <TContext> scenario, BridgeConfiguration <TLeft, TRight> config)
     where TContext : ScenarioContext
     where TLeft : TransportDefinition, new()
     where TRight : TransportDefinition, new()
 {
     return(scenario.WithComponent(new BridgeComponent <TLeft, TRight>(config)));
 }
예제 #3
0
 public SequenceBuilder(IScenarioWithEndpointBehavior <TContext> endpointBehavior, string step, Func <TContext, Task <bool> > handler)
 {
     this.endpointBehavior = endpointBehavior;
     sequence.Do(step, handler);
 }
예제 #4
0
 public static SequenceBuilder <TContext> Do <TContext>(this IScenarioWithEndpointBehavior <TContext> endpointBehavior, string step, Func <TContext, Task <bool> > handler)
     where TContext : ScenarioContext, ISequenceContext
 {
     return(new SequenceBuilder <TContext>(endpointBehavior, step, handler));
 }
예제 #5
0
        public static IScenarioWithEndpointBehavior <TContext> Done <TContext>(this IScenarioWithEndpointBehavior <TContext> endpointBehavior, Func <TContext, Task <bool> > func) where TContext : ScenarioContext
        {
            var behavior = new ServiceControlClient <TContext>(func);

            return(endpointBehavior.WithComponent(behavior).Done(ctx => behavior.Done));
        }
 public static IScenarioWithEndpointBehavior <TContext> WithPosionSpyComponent <TContext>(this IScenarioWithEndpointBehavior <TContext> scenario, Action <TransportExtensions <TestTransport> > transportConfiguration)
     where TContext : ScenarioContext
 {
     return(scenario.WithComponent(new PoisonSpyComponent(transportConfiguration)));
 }
 public static IScenarioWithEndpointBehavior <TContext> WithSpyComponent <TContext>(this IScenarioWithEndpointBehavior <TContext> scenario,
                                                                                    string endpointName,
                                                                                    Action <TransportExtensions <TestTransport> > transportConfiguration,
                                                                                    Func <TContext, MessageContext, IDispatchMessages, Task> onMessage)
     where TContext : ScenarioContext
 {
     return(scenario.WithComponent(new SpyComponent <TContext>(endpointName, transportConfiguration, onMessage)));
 }
    public static IScenarioWithEndpointBehavior <TContext> WithPosionSpyComponent <TContext>(this IScenarioWithEndpointBehavior <TContext> scenario, Action <TransportExtensions <TestTransport> > transportConfiguration)
        where TContext : ScenarioContext, IPoisonSpyContext
    {
        return(scenario.WithComponent(new SpyComponent <TContext>("poison", transportConfiguration, (scenarioContext, messageContext, dispatcher) =>
        {
            var failureDetected = 0;

            if (Interlocked.CompareExchange(ref failureDetected, 1, 0) == 0)
            {
                if (messageContext.Headers.TryGetValue("NServiceBus.ExceptionInfo.Message", out var exceptionMessage))
                {
                    scenarioContext.ExceptionMessage = exceptionMessage;
                }
                scenarioContext.PoisonMessageDetected = true;
            }
            return Task.CompletedTask;
        })));
    }
 public static IScenarioWithEndpointBehavior <TContext> With <TContext, TLeft, TRight>(this IScenarioWithEndpointBehavior <TContext> scenario, BridgeConfiguration <TLeft, TRight> config)
     where TContext : ScenarioContext
     where TLeft : TransportDefinition, new()
     where TRight : TransportDefinition, new()
 {
     return(scenario.WithComponent(new BridgeComponent <TLeft, TRight>(() =>
     {
         config.UseSubscriptionPersistence(new InMemorySubscriptionStorage());
         return config;
     })));
 }
예제 #10
0
    public static IScenarioWithEndpointBehavior <TContext> WithDelayedRetryEndpointComponent <TTransport, TContext>(this IScenarioWithEndpointBehavior <TContext> scenario, Action <TransportExtensions <TTransport> > customizeTransport, string name)
        where TContext : ScenarioContext
        where TTransport : TransportDefinition, new()
    {
        var component = new DelayedRetryEndpointComponent <TTransport, TContext>(name, customizeTransport);

        return(scenario.WithComponent(component));
    }
예제 #11
0
    public static IScenarioWithEndpointBehavior <TContext> WithRawSendOnlyEndpoint <TTransport, TContext>(this IScenarioWithEndpointBehavior <TContext> scenario,
                                                                                                          Action <TransportExtensions <TTransport> > customizeTransport,
                                                                                                          string name,
                                                                                                          Func <IRawEndpoint, TContext, Task> onStarting = null,
                                                                                                          Func <IRawEndpoint, TContext, Task> onStarted  = null,
                                                                                                          Action <RawEndpointConfiguration> configure    = null)
        where TContext : ScenarioContext
        where TTransport : TransportDefinition, new()
    {
        void configureWithTransport(RawEndpointConfiguration cfg)
        {
            configure?.Invoke(cfg);
            var ext = cfg.UseTransport <TTransport>();

            customizeTransport(ext);
        }

        var component = new RawEndpointComponent <TContext>(name, null, onStarting, onStarted, configureWithTransport);

        return(scenario.WithComponent(component));
    }