public UpdateBabySitterCommandTests() { var provider = ServiceProviderFactory.Create(); _context = provider.GetService <DatabaseContext>(); _command = new UpdateBabySitterCommand(_context, new SitterValidator()); }
public EndShiftCommandTests() { var provider = ServiceProviderFactory.Create(); _context = provider.GetService <DatabaseContext>(); _command = new EndShiftCommand(_context, new ShiftValidator()); }
/// <summary> /// Configures the services. /// </summary> /// <param name="services">The services.</param> public IServiceProvider ConfigureServices(IServiceCollection services) { // Add MVC and API controllers resolvers. services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; options.SerializerSettings.Converters.Add(new StringEnumConverter()); }); // Add data protection. Isolate the application from other applications. services.AddDataProtection(); services.Configure <FormOptions>(option => { option.MultipartBodyLengthLimit = 10485760; // 1024 * 1024 * 10; 10 MB }); // Reporting API versions will return the headers "api-supported-versions" and "api-deprecated-versions". services.AddApiVersioning(sa => { sa.ReportApiVersions = true; sa.DefaultApiVersion = new ApiVersion(1, 0); }); // Add DB connection. services.AddDbContext <CoreApiContext>(options => options.UseSqlite(Configuration.GetConnectionString("ComparerConnection"))); // DI framework factory. return(ServiceProviderFactory.Create(services)); }
public GetBabySitterShiftByIdQueryTests() { var provider = ServiceProviderFactory.Create(); _context = provider.GetService <DatabaseContext>(); _query = new GetBabySitterShiftByIdQuery(_context); }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> public static void Main(string[] args) { // Setup DI. IServiceProvider serviceProvider = ServiceProviderFactory.Create(GetServices()); App application = serviceProvider.GetService <App>(); application.Run(args); }
/// <summary> /// 以dto的形式调用服务 /// </summary> /// <param name="serviceName"></param> /// <param name="fillArg"></param> /// <returns></returns> public static DTObject Invoke(string serviceName, Action <DTObject> fillArg) { var arg = DTObject.CreateReusable(); if (fillArg != null) { fillArg(arg); } ServiceRequest request = new ServiceRequest(serviceName, DTObject.Empty, arg); var provider = ServiceProviderFactory.Create(request); return(provider.Invoke(request)); }
private void InvokeTestRun(TestRun testRun, TestRunExecutionContext context, TestRunResult result, ITestRunLogger logger) { context.TestRun = testRun; context.ServiceProvider = ServiceProviderFactory.Create(); OnBeforeTestRun(context); try { int stepNumber = 1; foreach (ITestRunStep testRunStep in testRun.Steps) { context.StepNumber = stepNumber++; InvokeStep(testRunStep, context, result, logger); } } finally { context.Step = null; var disposableServiceProvider = context.ServiceProvider as IDisposable; disposableServiceProvider?.Dispose(); OnAfterTestRun(context); } }
public object CachedProvider() => ServiceProviderFactory.Create <IConvertible, ICloneable, IComparable>(Value, Value, Value);