コード例 #1
0
        public void Default_visibility_can_be_changed()
        {
            var options = new DatabaseErrorPageOptions();
            options.SetDefaultVisibility(true);

            Assert.True(options.ShowExceptionDetails);
            Assert.True(options.ListMigrations);
        }
コード例 #2
0
        public void ListMigrations_overides_default_visibility()
        {
            var options = new DatabaseErrorPageOptions { ListMigrations = false };
            options.SetDefaultVisibility(true);

            Assert.True(options.ShowExceptionDetails);
            Assert.False(options.ListMigrations);
        }
コード例 #3
0
        public void Default_visibility_can_be_changed()
        {
            var options = new DatabaseErrorPageOptions();

            options.SetDefaultVisibility(true);

            Assert.True(options.ShowExceptionDetails);
            Assert.True(options.ListMigrations);
            Assert.True(options.EnableMigrationCommands);
        }
コード例 #4
0
        public void EnableMigrationCommands_overides_default_visibility()
        {
            var options = new DatabaseErrorPageOptions {
                EnableMigrationCommands = false
            };

            options.SetDefaultVisibility(true);

            Assert.True(options.ShowExceptionDetails);
            Assert.True(options.ListMigrations);
            Assert.False(options.EnableMigrationCommands);
        }
コード例 #5
0
        public async Task Exception_details_are_displayed()
        {
            var options = new DatabaseErrorPageOptions();

            options.SetDefaultVisibility(true);

            var model = new DatabaseErrorPageModel(
                contextType: typeof(BloggingContext),
                exception: new Exception("Something bad happened"),
                databaseExists: false,
                pendingModelChanges: false,
                pendingMigrations: new string[] { },
                options: options);

            var content = await ExecutePage(options, model);

            Assert.Contains("Something bad happened", content);
        }
コード例 #6
0
        public async Task Existing_database_with_migrations_and_pending_model_changes_only_displays_apply_migrations()
        {
            var options = new DatabaseErrorPageOptions();
            options.SetDefaultVisibility(true);

            var model = new DatabaseErrorPageModel(
                contextType: typeof(BloggingContext),
                exception: new Exception(),
                databaseExists: true,
                pendingModelChanges: true,
                pendingMigrations: new string[] { "111_MigrationOne" },
                options: options);

            var content = await ExecutePage(options, model);

            AssertHelpers.NotDisplaysScaffoldFirstMigration(typeof(BloggingContext), content);
            AssertHelpers.DisplaysApplyMigrations(typeof(BloggingContext), content);
            AssertHelpers.NotDisplaysScaffoldNextMigraion(typeof(BloggingContext), content);
        }
コード例 #7
0
        public async Task Existing_database_with_migrations_and_pending_model_changes_only_displays_apply_migrations()
        {
            var options = new DatabaseErrorPageOptions();

            options.SetDefaultVisibility(true);

            var model = new DatabaseErrorPageModel(
                contextType: typeof(BloggingContext),
                exception: new Exception(),
                databaseExists: true,
                pendingModelChanges: true,
                pendingMigrations: new string[] { "111_MigrationOne" },
                options: options);

            var content = await ExecutePage(options, model);

            AssertHelpers.NotDisplaysScaffoldFirstMigration(typeof(BloggingContext), content);
            AssertHelpers.DisplaysApplyMigrations(typeof(BloggingContext), content);
            AssertHelpers.NotDisplaysScaffoldNextMigraion(typeof(BloggingContext), content);
        }
コード例 #8
0
        public async Task MigrationsEndPointPath_is_respected()
        {
            var options = new DatabaseErrorPageOptions {
                MigrationsEndPointPath = new PathString("/HitThisEndPoint")
            };

            options.SetDefaultVisibility(true);

            var model = new DatabaseErrorPageModel(
                contextType: typeof(BloggingContext),
                exception: new Exception(),
                databaseExists: true,
                pendingModelChanges: false,
                pendingMigrations: new string[] { "111_MigrationOne" },
                options: options);

            var content = await ExecutePage(options, model);

            Assert.Contains(options.MigrationsEndPointPath.Value, content);
        }
コード例 #9
0
        public async Task ListMigrations_is_respected()
        {
            var options = new DatabaseErrorPageOptions {
                ListMigrations = false
            };

            options.SetDefaultVisibility(true);

            var model = new DatabaseErrorPageModel(
                contextType: typeof(BloggingContext),
                exception: new Exception(),
                databaseExists: true,
                pendingModelChanges: false,
                pendingMigrations: new string[] { "111_MigrationOne" },
                options: options);

            var content = await ExecutePage(options, model);

            Assert.DoesNotContain("111_MigrationOne", content);
        }
コード例 #10
0
        public async Task ShowExceptionDetails_is_respected()
        {
            var options = new DatabaseErrorPageOptions {
                ShowExceptionDetails = false
            };

            options.SetDefaultVisibility(true);

            var model = new DatabaseErrorPageModel(
                contextType: typeof(BloggingContext),
                exception: new Exception("Something bad happened"),
                databaseExists: false,
                pendingModelChanges: false,
                pendingMigrations: new string[] { },
                options: options);

            var content = await ExecutePage(options, model);

            Assert.DoesNotContain("Something bad happened", content);
        }
コード例 #11
0
        public async Task ListMigrations_is_respected()
        {
            var options = new DatabaseErrorPageOptions { ListMigrations = false };
            options.SetDefaultVisibility(true);

            var model = new DatabaseErrorPageModel(
               contextType: typeof(BloggingContext),
               exception: new Exception(),
               databaseExists: true,
               pendingModelChanges: false,
               pendingMigrations: new string[] { "111_MigrationOne" },
               options: options);

            var content = await ExecutePage(options, model);

            Assert.DoesNotContain("111_MigrationOne", content);
        }
コード例 #12
0
        public async Task ShowExceptionDetails_is_respected()
        {
            var options = new DatabaseErrorPageOptions { ShowExceptionDetails = false };
            options.SetDefaultVisibility(true);

            var model = new DatabaseErrorPageModel(
                contextType: typeof(BloggingContext),
                exception: new Exception("Something bad happened"),
                databaseExists: false,
                pendingModelChanges: false,
                pendingMigrations: new string[] { },
                options: options);

            var content = await ExecutePage(options, model);

            Assert.DoesNotContain("Something bad happened", content);
        }
コード例 #13
0
        public async Task Inner_exception_details_are_displayed()
        {
            var options = new DatabaseErrorPageOptions();
            options.SetDefaultVisibility(true);

            var model = new DatabaseErrorPageModel(
                contextType: typeof(BloggingContext),
                exception: new Exception("Something bad happened", new Exception("Because something more badder happened")),
                databaseExists: false,
                pendingModelChanges: false,
                pendingMigrations: new string[] { },
                options: options);

            var content = await ExecutePage(options, model);

            Assert.Contains("Something bad happened", content);
            Assert.Contains("Because something more badder happened", content);
        }