public void CreateTableOfTDto()
        {
            var logger = new DebugDiagnosticsLogger();

            var migrationRunner = new MigrationRunner(
                Mock.Of <IMigrationEntryService>(),
                logger,
                new SemVersion(0, 0, 0),
                new SemVersion(1, 0, 0),
                "Test",

                // explicit migrations
                new CreateTableOfTDtoMigration(SqlSyntax, logger)
                );

            var db = new UmbracoDatabase("Datasource=|DataDirectory|UmbracoPetaPocoTests.sdf;Flush Interval=1;", Constants.DatabaseProviders.SqlCe, Logger);

            var upgraded = migrationRunner.Execute(db, DatabaseProviders.SqlServerCE, true);

            Assert.IsTrue(upgraded);

            var helper = new DatabaseSchemaHelper(db, logger, SqlSyntax);
            var exists = helper.TableExist("umbracoNode");

            Assert.IsTrue(exists);
        }
Esempio n. 2
0
        private static IProfilingLogger GetTestProfilingLogger()
        {
            var logger   = new DebugDiagnosticsLogger();
            var profiler = new TestProfiler();

            return(new ProfilingLogger(logger, profiler));
        }
        public void DeleteKeysAndIndexesOfTDto()
        {
            var logger = new DebugDiagnosticsLogger();

            var builder = Mock.Of <IMigrationBuilder>();

            Mock.Get(builder)
            .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
            .Returns <Type, IMigrationContext>((t, c) =>
            {
                switch (t.Name)
                {
                case "CreateTableOfTDtoMigration":
                    return(new CreateTableOfTDtoMigration(c));

                case "DeleteKeysAndIndexesMigration":
                    return(new DeleteKeysAndIndexesMigration(c));

                default:
                    throw new NotSupportedException();
                }
            });

            using (var scope = ScopeProvider.CreateScope())
            {
                var upgrader = new Upgrader(
                    new MigrationPlan("test")
                    .From(string.Empty)
                    .To <CreateTableOfTDtoMigration>("a")
                    .To <DeleteKeysAndIndexesMigration>("done"));

                upgrader.Execute(ScopeProvider, builder, Mock.Of <IKeyValueService>(), logger);
                scope.Complete();
            }
        }
        public void CreateTableOfTDto()
        {
            var logger = new DebugDiagnosticsLogger();

            var builder = Mock.Of <IMigrationBuilder>();

            Mock.Get(builder)
            .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
            .Returns <Type, IMigrationContext>((t, c) =>
            {
                if (t != typeof(CreateTableOfTDtoMigration))
                {
                    throw new NotSupportedException();
                }
                return(new CreateTableOfTDtoMigration(c));
            });

            using (var scope = ScopeProvider.CreateScope())
            {
                var upgrader = new Upgrader(
                    new MigrationPlan("test")
                    .From(string.Empty)
                    .To <CreateTableOfTDtoMigration>("done"));

                upgrader.Execute(ScopeProvider, builder, Mock.Of <IKeyValueService>(), logger);

                var helper = new DatabaseSchemaCreator(scope.Database, logger);
                var exists = helper.TableExists("umbracoUser");
                Assert.IsTrue(exists);

                scope.Complete();
            }
        }
Esempio n. 5
0
        public void Setup()
        {
            var logger = new DebugDiagnosticsLogger();
            var path   = TestHelper.CurrentAssemblyDirectory;

            SetupSqlCe(path, logger);
            SetupSqlServer(logger);
        }
Esempio n. 6
0
        public async Task DebuggerInterferenceIssue()
        {
            var logger = new DebugDiagnosticsLogger();
            var runner = new BackgroundTaskRunner <IBackgroundTask>(new BackgroundTaskRunnerOptions {
                KeepAlive = true, LongRunning = true
            }, logger);
            var taskCompleted = false;

            runner.TaskCompleted += (sender, args) =>
            {
                Console.WriteLine("runner task completed");
                taskCompleted = true;
            };
            var work = new DebuggerInterferenceIssueWorkitem();

            // add the workitem to the runner and wait until it is running
            runner.Add(work);
            work.Running.Wait();

            // then wait a little bit more to ensure that the WhenAny has been entered
            await Task.Delay(500);

            // then break
            // when the timeout triggers, we cannot handle it
            // taskCompleted value does *not* change & nothing happens
            Debugger.Break();

            // release after 15s
            // WhenAny should return the timeout task
            // and then taskCompleted should turn to true
            // = debugging does not prevent task completion

            Console.WriteLine("*");
            Assert.IsFalse(taskCompleted);
            await Task.Delay(1000);

            Console.WriteLine("*");
            Assert.IsTrue(taskCompleted);
        }
Esempio n. 7
0
        public async Task ThreadResumeIssue()
        {
            var logger = new DebugDiagnosticsLogger();
            var runner = new BackgroundTaskRunner <IBackgroundTask>(new BackgroundTaskRunnerOptions {
                KeepAlive = true, LongRunning = true
            }, logger);
            var work = new ThreadResumeIssueWorkItem();

            runner.Add(work);

            Console.WriteLine("running");
            await Task.Delay(1000); // don't complete too soon

            Console.WriteLine("completing");

            // this never returned, never reached "completed" because the same thread
            // resumed executing the waiting on queue operation in the runner
            work.Complete();
            Console.WriteLine("completed");

            Console.WriteLine("done");
        }
        public void Issue8361Test()
        {
            var logger = new DebugDiagnosticsLogger();

            //Setup the MigrationRunner
            var migrationRunner = new MigrationRunner(
                Mock.Of <IMigrationEntryService>(),
                logger,
                new SemVersion(7, 4, 0),
                new SemVersion(7, 5, 0),
                Constants.System.UmbracoMigrationName,

                //pass in explicit migrations
                new DeleteRedirectUrlTable(SqlSyntax, logger),
                new AddRedirectUrlTable(SqlSyntax, logger)
                );

            var db = new UmbracoDatabase("Datasource=|DataDirectory|UmbracoPetaPocoTests.sdf;Flush Interval=1;", Constants.DatabaseProviders.SqlCe, Logger);

            var upgraded = migrationRunner.Execute(db, DatabaseProviders.SqlServerCE, true);

            Assert.IsTrue(upgraded);
        }
Esempio n. 9
0
            protected override IRuntime GetRuntime()
            {
                var logger = new DebugDiagnosticsLogger();

                return(Runtime = new TestRuntime(logger, new MainDom(logger, new MainDomSemaphoreLock(logger))));
            }