コード例 #1
0
        private IPersistence Create()
        {
            Connect();

            _logger.LogInformation("Starting test #{number}", _testRunId);

            _options = new SqlitePersistenceOptions(LoggerFactory)
            {
                ConnectionString = ConnectionString,
                StreamsTableName = "streams_" + _testRunId + "_" + GetType().Name,
                Serializer       = new JsonMsSqlSerializer()
            };

            _sqlPersistence = new SqlitePersistence(_options);
            _sqlPersistence.DestroyAllAsync(CancellationToken.None).Wait();
            _sqlPersistence.InitAsync(CancellationToken.None).Wait();
            _logger.LogInformation("Test #{number} started", _testRunId);
            return(_sqlPersistence);
        }
コード例 #2
0
        private static SqlitePersistenceOptions BuildOptions()
        {
            var id = Interlocked.Increment(ref Id);

            var pathToDb = Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), $"test_batch_{id}.db");

            if (File.Exists(pathToDb))
            {
                File.Delete(pathToDb);
            }

            var options = new SqlitePersistenceOptions(NStoreNullLoggerFactory.Instance)
            {
                ConnectionString = $"Data Source={pathToDb}",
                Serializer       = new SqliteSerializer()
            };

            return(options);
        }
コード例 #3
0
        public AppEngine()
        {
            var pathToDb = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "sample.db");

            if (File.Exists(pathToDb))
            {
                File.Delete(pathToDb);
            }

            var options = new SqlitePersistenceOptions(new NStore.Core.Logging.NStoreNullLoggerFactory())
            {
                ConnectionString = $"Data Source={pathToDb}",
                Serializer       = new TypeAsSchemaJsonSerializer()
            };
            var persitence = new SqlitePersistence(options);

            _streams = new StreamsFactory(persitence);

            SQLitePCL.Batteries_V2.Init();

            persitence.InitAsync(CancellationToken.None).GetAwaiter().GetResult();
        }
コード例 #4
0
        protected IPersistence Create(bool dropOnInit)
        {
            Connect();

            _logger.LogInformation("Starting test #{number}", _testRunId);

            var options = new SqlitePersistenceOptions(LoggerFactory)
            {
                ConnectionString = ConnectionString,
                StreamsTableName = "streams_" + _testRunId + "_" + GetType().Name,
                Serializer       = new JsonSqliteSerializer()
            };

            var sqlPersistence = new SqlitePersistence(options);

            if (dropOnInit)
            {
                sqlPersistence.DestroyAllAsync(CancellationToken.None).Wait();
            }

            sqlPersistence.InitAsync(CancellationToken.None).Wait();
            _logger.LogInformation("Test #{number} started", _testRunId);
            return(sqlPersistence);
        }