Exemplo n.º 1
0
        protected Scenario(HttpClient?client, Action <string> logMessage, IBadRequestProvider badRequestProvider,
                           IServiceProvider?services, int?maxElapsedTime, EventAggregator eventAggregator,
                           JsonSerializerOptions?jsonDeserializeOptions,
                           JsonSerializerOptions?jsonSerializeOptions)
        {
            _client = client ?? throw new BardConfigurationException("client not set.");

            if (badRequestProvider is BadRequestProviderBase badRequestProviderBase)
            {
                badRequestProviderBase.SetSerializer(new BardJsonSerializer(jsonDeserializeOptions,
                                                                            jsonSerializeOptions));
            }

            _badRequestProvider = badRequestProvider;
            _eventAggregator    = eventAggregator;

            LogWriter = new LogWriter(logMessage, _eventAggregator,
                                      new BardJsonSerializer(jsonDeserializeOptions, jsonSerializeOptions));

            var pipeline = new PipelineBuilder(LogWriter);

            Context = new ScenarioContext(pipeline, FullLoggingApi(), LogWriter, services);

            var when = new When.When(RequestLoggingApi(), _eventAggregator, LogWriter);

            InternalWhen = when;

            _then = new Then.Then(maxElapsedTime, LogWriter);

            _eventAggregator.Subscribe(_then);
            _eventAggregator.Subscribe(pipeline);
        }
Exemplo n.º 2
0
        protected Scenario(HttpClient?client, Action <string> logMessage, IBadRequestProvider badRequestProvider,
                           IServiceProvider?services, int?maxElapsedTime)
        {
            _client             = client ?? throw new BardConfigurationException("client not set.");
            _badRequestProvider = badRequestProvider;
            _eventAggregator    = new EventAggregator();

            LogWriter = new LogWriter(logMessage, _eventAggregator);

            var pipeline = new PipelineBuilder(LogWriter);

            Context = new ScenarioContext(pipeline, FullLoggingApi(), LogWriter, services);

            var when = new When.When(RequestLoggingApi(), LogWriter);

            InternalWhen = when;

            _then = new Then.Then(maxElapsedTime);

            _eventAggregator.Subscribe(_then);
            _eventAggregator.Subscribe(pipeline);
        }