Esempio n. 1
0
        internal Scenario(GrpcScenarioOptions options)
        {
            if (options.GrpcClients.Any() == false && options.Client == null)
            {
                throw new BardConfigurationException("Client not set");
            }

            _eventAggregator = new EventAggregator();

            _logWriter = new LogWriter(options.LogMessage, _eventAggregator);

            var originalClient = options.Client ?? throw new BardConfigurationException("client not set.");

            var bardClient = HttpClientBuilder
                             .CreateFullLoggingClient(originalClient, _logWriter, options.BadRequestProvider, _eventAggregator);

            _clientFactory = new GrpcClientFactory(options.GrpcClients, bardClient, _logWriter);

            _api = new Api(bardClient);

            var pipeline = new PipelineBuilder(_logWriter);

            Context = new GrpcScenarioContext(pipeline, _api, _logWriter,
                                              options.Services, _clientFactory);

            _when = new When(_api, _eventAggregator, _logWriter);

            _then = new Then(null, _logWriter);

            _eventAggregator.Subscribe(_then);
            _eventAggregator.Subscribe(pipeline);
        }
Esempio n. 2
0
 public Context(IWho who, IWhat what, IWhere where, IWhen when, IWhy why)
 {
     Who   = who;
     What  = what;
     Where = where;
     When  = when;
     Why   = why;
 }
Esempio n. 3
0
        public static async Task MakeTheRequest <T>(this IWhen <T> when,
                                                    string uri,
                                                    HttpMethod method = null,
                                                    string body       = null)
            where T : class, IHasServer, IHasResponse
        {
            var client = when.Context.FakeServer.GetClient();

            await MakeTheRequest <T>(when, client, uri, method, body);
        }
Esempio n. 4
0
        public static async Task MakeTheRequest <T>(this IWhen <T> when,
                                                    HttpClient client,
                                                    string uri,
                                                    HttpMethod method = null,
                                                    string body       = null)
            where T : class, IHasServer, IHasResponse
        {
            var message = new HttpRequestMessage(method ?? HttpMethod.Get, new Uri(uri));

            if (!string.IsNullOrEmpty(body))
            {
                message.Content = new StringContent(body);
            }

            when.Context.ResponseMessage = await client.SendAsync(message);
        }
Esempio n. 5
0
 public static async Task IDivideBy(this IWhen <TestContext> when, int divisor)
 {
     when.Context.Final = when.Context.Added / (double)divisor;
     await Task.Delay(1);
 }
Esempio n. 6
0
 public static async Task IAddTheValues(this IWhen <TestContext> when)
 {
     when.Context.Added = when.Context.FirstValue + when.Context.SecondValue;
     await Task.Delay(1);
 }
Esempio n. 7
0
 public static ICaseEnd <T> CASE <T>(IWhen <T> caseExpression)
 {
     throw new NotSupportedException();
 }
Esempio n. 8
0
 public static async Task MethodIsCalledAsync <T>(this IWhen <EntityContext <T> > when, Func <T, Task> action)
     where T : EntityBase
 {
     await action(when.Context.Entity);
 }
Esempio n. 9
0
 public static async Task CreateTheEntity <T>(this IWhen <EntityContext <T> > when)
     where T : EntityBase
 {
     when.Context.Entity = await when.Context.EntityService.NewEntity();
 }
Esempio n. 10
0
 public PrimeRequest(IWhen @when, IThen then)
 {
     _when = when;
     _then = then;
 }
 public static void IDivideBy(this IWhen <TestContext> when, int divisor)
 {
     when.Context.Final = when.Context.Added / (double)divisor;
 }
 public static void IAddTheValues(this IWhen <TestContext> when)
 {
     when.Context.Added = when.Context.FirstValue + when.Context.SecondValue;
 }