Ejemplo n.º 1
0
        public void Setup()
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            var config = TestsHelper.GetConfig();
            var env    = TestsHelper.GetEnvironment();

            var connectionString = config.GetConnectionString("DefaultConnection");
            var logPath          = config.GetValue <string>("LogPath");

            logger      = new Logger(logPath);
            tDispatcher = new Dispatcher();
            con         = new SqliteConnection("DataSource=:memory:");
            con.Open();
            dbContextOptionsBuilder = new DbContextOptionsBuilder <PuckContext>();
            dbContextOptionsBuilder
            .UseSqlite(con);
            context = new PuckContext(dbContextOptionsBuilder.Options);
            repo    = new Puck_Repository(context);
            var dbCreated       = repo.Context.Database.EnsureCreated();
            var indexerSearcher = new Content_Indexer_Searcher(logger, config, env);

            indexer                   = indexerSearcher;
            searcher                  = indexerSearcher;
            roleManager               = MockHelpers.MockRoleManager <PuckRole>().Object;
            userManager               = MockHelpers.MockUserManager().Object;
            apiHelper                 = new ApiHelper(roleManager, userManager, repo, tDispatcher, indexer, logger);
            contentService            = new ContentService(config, roleManager, userManager, repo, tDispatcher, indexer, logger, apiHelper);
            PuckCache._puckSearcher   = searcher;
            PuckCache.ServiceProvider = MockHelpers.MockServiceProvider(repo).Object;
            PuckCache.MaxRevisions    = 20;
            TestsHelper.SetAQNMappings();
            TestsHelper.SetAnalyzerMappings();
            indexer.DeleteAll();
        }
Ejemplo n.º 2
0
        public I_Puck_Repository NewRepo()
        {
            var context = new PuckContext(dbContextOptionsBuilder.Options);

            repo = new Puck_Repository(context);
            return(repo);
        }
Ejemplo n.º 3
0
        public I_Puck_Repository NewRepo(string type)
        {
            var services = ServiceDictionary[type];
            var context  = new PuckContext(services.DbContextOptionsBuilder.Options);
            var repo     = new Puck_Repository(context);

            return(repo);
        }