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); }
public Context(IWho who, IWhat what, IWhere where, IWhen when, IWhy why) { Who = who; What = what; Where = where; When = when; Why = why; }
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); }
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); }
public static async Task IDivideBy(this IWhen <TestContext> when, int divisor) { when.Context.Final = when.Context.Added / (double)divisor; await Task.Delay(1); }
public static async Task IAddTheValues(this IWhen <TestContext> when) { when.Context.Added = when.Context.FirstValue + when.Context.SecondValue; await Task.Delay(1); }
public static ICaseEnd <T> CASE <T>(IWhen <T> caseExpression) { throw new NotSupportedException(); }
public static async Task MethodIsCalledAsync <T>(this IWhen <EntityContext <T> > when, Func <T, Task> action) where T : EntityBase { await action(when.Context.Entity); }
public static async Task CreateTheEntity <T>(this IWhen <EntityContext <T> > when) where T : EntityBase { when.Context.Entity = await when.Context.EntityService.NewEntity(); }
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; }