Exemple #1
0
        private void DeleteAllData()
        {
            var conn = ConnectionUtil.GetConnectionString();

            using (var connection = ConnectionUtil.CreateConnection(conn))
            {
                connection.Execute($@"
TRUNCATE TABLE cap.published;
TRUNCATE TABLE cap.received;");
            }
        }
Exemple #2
0
        protected DatabaseTestHost()
        {
            Logger          = new Mock <ILogger <SqlServerStorage> >().Object;
            CapOptions      = new Mock <CapOptions>().Object;
            SqlSeverOptions = new SqlServerOptions()
            {
                ConnectionString = ConnectionUtil.GetConnectionString()
            };

            DiagnosticProcessorObserver = new DiagnosticProcessorObserver(new Mock <IDispatcher>().Object);

            InitializeDatabase();
        }
Exemple #3
0
        private void CreateServiceCollection()
        {
            var services = new ServiceCollection();

            services.AddOptions();
            services.AddLogging();

            _connectionString = ConnectionUtil.GetConnectionString();
            services.AddSingleton(new SqlServerOptions {
                ConnectionString = _connectionString
            });
            services.AddSingleton <SqlServerStorage>();

            _services = services;
        }
Exemple #4
0
        private void CreateServiceCollection()
        {
            var services = new ServiceCollection();

            services.AddOptions();
            services.AddLogging();

            _connectionString = ConnectionUtil.GetConnectionString();
            services.AddSingleton(new SqlServerOptions {
                ConnectionString = _connectionString
            });
            services.AddSingleton <SqlServerStorage>();
            services.AddDbContext <TestDbContext>(options => options.UseSqlServer(_connectionString));

            _services = services;
        }
Exemple #5
0
        private void CreateServiceCollection()
        {
            var services = new ServiceCollection();

            services.AddOptions();
            services.AddLogging();

            ConnectionString = ConnectionUtil.GetConnectionString();
            services.AddOptions <CapOptions>();
            services.Configure <SqlServerOptions>(x =>
            {
                x.ConnectionString = ConnectionString;
            });
            services.AddSingleton <SqlServerDataStorage>();
            services.AddSingleton <IStorageInitializer, SqlServerStorageInitializer>();
            _services = services;
        }
Exemple #6
0
        protected DatabaseTestHost()
        {
            Logger = new Mock <ILogger <SqlServerStorage> >().Object;

            var capOptions = new Mock <IOptions <CapOptions> >();

            capOptions.Setup(x => x.Value).Returns(new CapOptions());
            CapOptions = capOptions.Object;

            var options = new Mock <IOptions <SqlServerOptions> >();

            options.Setup(x => x.Value).Returns(new SqlServerOptions {
                ConnectionString = ConnectionUtil.GetConnectionString()
            });
            SqlSeverOptions = options.Object;

            DiagnosticProcessorObserver = new DiagnosticProcessorObserver(new Mock <IDispatcher>().Object);

            InitializeDatabase();
        }
Exemple #7
0
        private void DeleteAllData()
        {
            var conn = ConnectionUtil.GetConnectionString();

            using (var connection = new SqlConnection(conn))
            {
                var commands = new[] {
                    "DISABLE TRIGGER ALL ON ?",
                    "ALTER TABLE ? NOCHECK CONSTRAINT ALL",
                    "DELETE FROM ?",
                    "ALTER TABLE ? CHECK CONSTRAINT ALL",
                    "ENABLE TRIGGER ALL ON ?"
                };

                foreach (var command in commands)
                {
                    connection.Execute(
                        "sp_MSforeachtable",
                        new { command1 = command },
                        commandType: CommandType.StoredProcedure);
                }
            }
        }
Exemple #8
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var connectionString = ConnectionUtil.GetConnectionString();

            optionsBuilder.UseSqlServer(connectionString);
        }