public async Task InitializeAsync() { _settingsPath = Path.GetFullPath(Path.Combine($"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}", @"..\..\..\settings")); _indexPath = $"{_settingsPath}\\PersonalBlog\\index"; _mockLocalIndexPathFactory = new Mock <ILocalIndexPathFactory>(); _mockLocalIndexPathFactory.Setup(x => x.GetLocalIndexPath()) .Returns(_indexPath); var services = new ServiceCollection() .AddLuceneDocumentMapper() .AddLuceneProvider() .AddLogging(x => x.AddConsole()); services.Add(new ServiceDescriptor(typeof(ILocalIndexPathFactory), _mockLocalIndexPathFactory.Object)); _serviceProvider = services.BuildServiceProvider(); var dateTime = DateTime.Now; _indexProvider = _serviceProvider.GetService <IIndexProvider>(); await _indexProvider.CreateIndexIfNotExists(typeof(BlogPost)); await _indexProvider.Store(new List <BlogPost> { new BlogPost { Name = "My Test Blog Post", Id = "1", PublishedDate = DateTime.Now.AddDays(-1) }, new BlogPost { Name = "My Test Blog Post", Id = "2", PublishedDate = DateTime.Now.AddDays(-100) }, new BlogPost { Name = "My Test Blog Post", Id = "3", PublishedDate = DateTime.Now.AddDays(-120) }, new BlogPost { Name = "My Test Blog Post", Id = "4", PublishedDate = DateTime.Now.AddDays(-11) }, new BlogPost { Name = "My Test Blog Post", Id = "5", PublishedDate = DateTime.Now.AddDays(-19) }, new BlogPost { Name = "My Test Blog Post", Id = "6", PublishedDate = DateTime.Now.AddDays(-13) }, new BlogPost { Name = "My Test Blog Post", Id = "7", PublishedDate = DateTime.Now.AddDays(-7) }, new BlogPost { Name = "My Test Blog Post", Id = "8", PublishedDate = DateTime.Now.AddDays(-8) }, new BlogPost { Name = "My Test Blog Post", Id = "9", Body = "My test body", Tags = new List <Tag>() { new Tag() { Id = "1", Name = "my-test-tag" } }, PublishedDate = DateTime.Now.AddDays(-9) }, new BlogPost { Name = "My Test Blog Post", Id = "10", TagIds = new List <string>() { "11", "2" }, PublishedDate = DateTime.Now.AddDays(-10) } }); }