public static void Run() { var store = new EmbeddableDocumentStore(); store.Initialize(); store.Conventions.AllowQueriesOnId = true; var context = new RavenDbContext(store); var serviceCollection = new ServiceCollection(); serviceCollection.Singleton<IDocumentStore>(provider => store); serviceCollection.Scoped<IUnitOfWork, RavenDbContext>(); serviceCollection.Scoped(typeof(IRepository<>), typeof(RavenDbRepository<>)); serviceCollection.Update(); }
public static void Run() { var serviceCollection = new ServiceCollection(); var dictionary = new Dictionary<int, object>(); dictionary.Add(typeof(MongoSettings).GetHashCode(), new MongoSettings { DatabaseName = "MetadataStore", Host = "localhost", Port = 27017, Timeout = 2 }); // Register ISettingsProvider as singleton.; var provider = new DictionarySettingProvider(dictionary); serviceCollection.Singleton<ISettingsProvider>(p => provider); serviceCollection.Scoped<IUnitOfWork, MongoContext>(); serviceCollection.Scoped(typeof(IRepository<>), typeof(MongoRepository<>)); // Update registration. serviceCollection.Update(); }
public static void Init(TestContext testContext) { var serviceCollection = new ServiceCollection(); // Register ISettingsProvider as singleton.; var provider = Substitute.For<ISettingsProvider>(); provider .Get<MongoSettings>() .Returns(settings); serviceCollection.Singleton<ISettingsProvider>(p => provider); // Update registration. serviceCollection.Update(); // Check if MongoDB is alive. Yekzen.QualityTools.UnitTest.ExceptionAssert.InconclusiveWhenThrows<UnreachableException>(() => { new MongoContext(); }); }