예제 #1
0
        static int Main(string[] args)
        {
            try
            {
                var appRootFolder = AppDomain.CurrentDomain.BaseDirectory;
                var logProvider   = new ConsoleLogProvider();
                var host          = Host.Find(appRootFolder, logProvider);
                var configuration = host.RhetosRuntime.BuildConfiguration(logProvider, host.ConfigurationFolder,
                                                                          configurationBuilder => configurationBuilder.AddConfigurationManagerConfiguration());

                LegacyUtilities.Initialize(configuration);

                string connectionString = SqlUtility.ConnectionString;
                Console.WriteLine("SQL connection: " + SqlUtility.SqlConnectionInfo(connectionString));
                var sqlExecuter = GetSqlExecuterImplementation(connectionString);

                var databaseCleaner = new DatabaseCleaner(new ConsoleLogProvider(), sqlExecuter);
                databaseCleaner.DeleteAllMigrationData();
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine(ex);
                if (Environment.UserInteractive)
                {
                    Thread.Sleep(3000);
                }
                return(1);
            }
        }
예제 #2
0
        public void ShouldClearAndInsert()
        {
            var databaseCleaner = new DatabaseCleaner();

            databaseCleaner.ConnectTo("Server=localhost;Database=database;User Id=user;Password=password;");
            databaseCleaner.CleanAndInsert(@"Datasets\Template.xml");
        }
예제 #3
0
        public static void AddHangFireServices(this IServiceCollection services, string mongoConnectionString, string database, bool clearHangfireDb = false)
        {
            var serviceProvider = services.BuildServiceProvider();
            var env             = serviceProvider.GetService <IHostingEnvironment>();

            if (clearHangfireDb && env.IsDevelopment())
            {
                DatabaseCleaner.ClearDatabase(mongoConnectionString, database);
            }

            services.AddHangfire(config =>
            {
                var storageOption = new MongoStorageOptions()
                {
                    QueuePollInterval = TimeSpan.FromMilliseconds(200)
                };
                config.UseMongoStorage(mongoConnectionString, database, storageOption);
            });

            services.AddSingleton <IEventHandlerRegistry, EventHandlerRegistry>();

            services.AddSingleton <IEventProcessor, EventProcessor>();

            services.AddTransient <IJobService, JobService>();
        }
예제 #4
0
        static int Main(string[] args)
        {
            try
            {
                Paths.InitializeRhetosServerRootPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".."));

                string connectionString = SqlUtility.ConnectionString;
                Console.WriteLine("SQL connection string: " + SqlUtility.MaskPassword(connectionString));
                var sqlExecuter = GetSqlExecuterImplementation(connectionString);

                var databaseCleaner = new DatabaseCleaner(new ConsoleLogProvider(), sqlExecuter);
                databaseCleaner.DeleteAllMigrationData();
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                DeploymentUtility.WriteError(ex.Message);
                Console.WriteLine("Details:");
                Console.WriteLine(ex);
                if (Environment.UserInteractive)
                {
                    Thread.Sleep(3000);
                }
                return(1);
            }
        }
        // ToDo: Refactor this ugly test.
        //[TestMethod]
        public void BeAbleToClearTheEmptyDatabase()
        {
            ConfigureLog4NetSmtp();
            var logger = GetLogger();

            var session = Context.CurrentSession();
            var emptyDb = new EmptyDatabase {
                IsEmpty = false
            };

            try
            {
                session.Save(emptyDb);

                Assert.AreEqual(1, session.Query <EmptyDatabase>().Count());
            }
            catch (System.Exception e)
            {
                logger.Fatal(e);
                Assert.Fail(e.ToString());
            }

            try
            {
                DatabaseCleaner.CleanDataBase(session);

                Assert.AreEqual(0, session.Query <EmptyDatabase>().Count());
            }
            catch (System.Exception e)
            {
                logger.Fatal(e);
                Assert.Fail(e.ToString());
            }
        }
        public static void BeforeTestRun()
        {
            var cleaning = DatabaseCleaner.Clean();

            IIS.Instance.Start();
            Driver.Instance.Start();
            cleaning.Wait();
        }
예제 #7
0
        public void TestCleanupOldData(string description,
                                       string oldTables, string oldSchemas,
                                       string expectedDeletedTables, string expectedDeletedSchemas)
        {
            var mockSqlExecuter = new MockSqlExecuter("", oldTables, oldSchemas);
            var databaseCleaner = new DatabaseCleaner(new ConsoleLogProvider(), mockSqlExecuter);

            Console.WriteLine("Report: " + databaseCleaner.DeleteAllMigrationData());

            Assert.AreEqual("", TestUtility.DumpSorted(mockSqlExecuter.DroppedColumns), description + ": Deleted columns.");
            Assert.AreEqual(expectedDeletedTables, TestUtility.DumpSorted(mockSqlExecuter.DroppedTables), description + ": Deleted tables.");
            Assert.AreEqual(expectedDeletedSchemas, TestUtility.DumpSorted(mockSqlExecuter.DroppedSchemas), description + ": Deleted schemas.");
        }
예제 #8
0
        public void TestCleanupRedundantOldData(string description,
                                                string oldColumns, string oldTables, string oldSchemas,
                                                string expectedDeletedColumns, string expectedDeletedTables, string expectedDeletedSchemas)
        {
            var mockSqlExecuter = new MockSqlExecuter(oldColumns, oldTables, oldSchemas);
            var databaseCleaner = new DatabaseCleaner(new ConsoleLogProvider(), mockSqlExecuter);

            databaseCleaner.RemoveRedundantMigrationColumns();

            Assert.AreEqual(expectedDeletedColumns, TestUtility.DumpSorted(mockSqlExecuter.DroppedColumns), description + ": Deleted columns.");
            Assert.AreEqual(expectedDeletedTables, TestUtility.DumpSorted(mockSqlExecuter.DroppedTables), description + ": Deleted tables.");
            Assert.AreEqual(expectedDeletedSchemas, TestUtility.DumpSorted(mockSqlExecuter.DroppedSchemas), description + ": Deleted schemas.");
        }
예제 #9
0
        protected override void OnStart(string[] args)
        {
            try
            {
                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

                var configuration = Settings.LoadSettings();

                watcher = new Watcher(configuration);
                watcher.Start();
                log.Info("FileSystemWatcher started");

                poster = new AutoPoster(configuration);
                poster.Start();
                log.Info("Autoposter started");

                notifier = IndexerNotifierBase.GetActiveNotifier(configuration);
                if (notifier != null)
                {
                    notifier.Start();
                    log.Info("Notifier started");
                }
                else
                {
                    log.Info("No notifier");
                }

                verifier = IndexerVerifierBase.GetActiveVerifier(configuration);
                if (verifier != null)
                {
                    verifier.Start();
                    log.Info("Verifier started");
                }
                else
                {
                    log.Info("No verifier");
                }

                cleaner = new DatabaseCleaner(configuration);
                cleaner.Start();
                log.Info("DB Cleaner started");
            }
            catch (Exception ex)
            {
                log.Fatal("Fatal exception when starting the autoposter.", ex);
                throw;
            }
        }
예제 #10
0
        public void ListDisplaysAddedCandidates()
        {
            // prepare
            DatabaseCleaner.ClearCandidates();

            var addCommand = Container.Resolve <AddCandidate>();

            addCommand.FirstName = "test first";
            addCommand.LastName  = "test second";
            addCommand.Email     = "*****@*****.**";

            addCommand.Execute();

            // select
            var query  = Container.Resolve <CandidateQuery>();
            var result = query.GetForList();

            Assert.That(result.Count(), Is.EqualTo(1));
            var row = result.First();

            Assert.That(row.FirstName, Is.EqualTo("test first"));
            Assert.That(row.LastName, Is.EqualTo("test second"));
        }
예제 #11
0
        public void NewlyAddedCandidatesAreDisplayedFirst()
        {
            // prepare
            DatabaseCleaner.ClearCandidates();

            var addCommand = Container.Resolve <AddCandidate>();

            addCommand.FirstName = "fname1";
            addCommand.LastName  = "lname1";
            addCommand.Email     = "*****@*****.**";

            addCommand.Execute();

            // make sure on db you'll have different datetimes
            Thread.Sleep(10);

            addCommand           = Container.Resolve <AddCandidate>();
            addCommand.FirstName = "fname2";
            addCommand.LastName  = "lname2";
            addCommand.Email     = "*****@*****.**";

            addCommand.Execute();

            // select
            var query  = Container.Resolve <CandidateQuery>();
            var result = query.GetForList().ToList();

            Assert.That(result.Count(), Is.EqualTo(2));

            // check order
            var firstRow = result[0];

            Assert.That(firstRow.FirstName, Is.EqualTo("fname2"));
            var secondRow = result[1];

            Assert.That(secondRow.FirstName, Is.EqualTo("fname1"));
        }
예제 #12
0
 public void Init()
 {
     DatabaseCleaner.Clean();
 }
예제 #13
0
 public void Init()
 {
     DatabaseCleaner.Clean();
     EntitiesContext = GetContext();
 }
예제 #14
0
 public EntitySerializationAndDeserializationTests()
 {
     DatabaseCleaner.CleanupTestDatabaseAsync().GetAwaiter();
 }
예제 #15
0
 private async Task CleanDatabase(string connectionString)
 {
     await DatabaseCleaner.CleanUp(connectionString);
 }
예제 #16
0
 private async Task CleanDatabase()
 {
     await DatabaseCleaner.CleanUp(ConnectionStrings.BlogPostgreSQLConnection);
 }
예제 #17
0
 public DocumentDbNotificationsClientTests()
 {
     DatabaseCleaner.CleanupTestDatabaseAsync().GetAwaiter();
 }
 public void ShouldClearAndInsert()
 {
     var databaseCleaner = new DatabaseCleaner();
     databaseCleaner.ConnectTo("Server=localhost;Database=database;User Id=user;Password=password;");
     databaseCleaner.CleanAndInsert(@"Datasets\Template.xml");
 }