// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); var ravenDbOptions = Configuration.AddRavenDbConfiguration(); var ravenDbSetupOptions = new RavenDbSetupOptions { DocumentCollections = FakeData() }; services.AddSimpleRavenDb(ravenDbOptions, ravenDbSetupOptions); }
public async Task GivenTheBareMinimum_SetupRavenDb_SetsUpADatabase(IEnumerable <IList> fakeData, Type indexAssembly) { // Arrange. var logger = new Mock <ILogger>(); var documentStore = GetDocumentStore(); // Act. var setupOptions = new RavenDbSetupOptions { DocumentCollections = fakeData, IndexAssembly = indexAssembly }; await documentStore.SetupRavenDbAsync(setupOptions, logger.Object, default); // Assert. WaitForIndexing(documentStore); var statistics = documentStore.Maintenance.Send(new GetStatisticsOperation()); statistics.Indexes.Length.ShouldBe(indexAssembly is null ? 0 : 1); if (fakeData?.Any() == true) { statistics.CountOfDocuments.ShouldBeGreaterThan(0); using (var asyncSession = documentStore.OpenAsyncSession()) { var fakeUser = await asyncSession.LoadAsync <FakeUser>("fakeUsers/1-a"); fakeUser.ShouldNotBeNull(); } } documentStore.Dispose(); }