public static IServiceCollection BuildTestServiceCollection(bool useBls = true, bool useStore = false) { var services = new ServiceCollection(); var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.Development.json") .Build(); services.AddSingleton <IConfiguration>(configuration); services.AddLogging(configure => configure.AddConsole()); services.AddBeaconNode(configuration); if (!useBls) { // NOTE: Can't mock ByRef Span<T> var testCryptographyService = new TestCryptographyService(); services.AddSingleton <ICryptographyService>(testCryptographyService); } if (useStore) { services.AddSingleton <IStoreProvider, MemoryStoreProvider>(); } return(services); }
public static IServiceProvider BuildTestServiceProvider(bool useBls = true) { var services = new ServiceCollection(); services.AddLogging(configure => configure.AddConsole()); var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.Development.json") .Build(); services.AddBeaconNode(configuration); if (!useBls) { // NOTE: Can't mock ByRef Span<T> var testCryptographyService = new TestCryptographyService(); services.AddSingleton <ICryptographyService>(testCryptographyService); } var options = new ServiceProviderOptions() { ValidateOnBuild = false }; return(services.BuildServiceProvider(options)); }