<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Tests.TestHelpers;
using umbraco.interfaces;
using Umbraco.Core.Persistence;

namespace Umbraco.Tests.BootManagers
{
    [TestFixture]
    public class CoreBootManagerTests : BaseUmbracoApplicationTest
    {

        private TestApp _testApp;

        [SetUp]
        public override void Initialize()
        {
            base.Initialize();
            _testApp = new TestApp();            
        }

        [TearDown]
        public override void TearDown()
        {
            base.TearDown();

            _testApp = null;            
        }

        /// <summary>
        /// Inheritors can override this if they wish to create a custom application context
        /// </summary>
        protected override void SetupApplicationContext()
        {
            base.SetupApplicationContext();

            var dbContextMock = new Mock<DatabaseContext>(Mock.Of<IDatabaseFactory>(), Mock.Of<ILogger>(), Mock.Of<ISqlSyntaxProvider>(), "test");
            dbContextMock.Setup(x => x.CanConnect).Returns(true);
            ApplicationContext.DatabaseContext = dbContextMock.Object;
        }

        protected override void FreezeResolution()
        {
            //don't freeze resolution, we'll do that in the boot manager
        }

        /// <summary>
        /// test application using a CoreBootManager instance to boot
        /// </summary>
        public class TestApp : UmbracoApplicationBase
        {
            protected override IBootManager GetBootManager()
            {
                return new TestBootManager(this);
            }
        }

        /// <summary>
        /// Test boot manager to add a custom application event handler
        /// </summary>
        public class TestBootManager : CoreBootManager
        {
            public TestBootManager(UmbracoApplicationBase umbracoApplication)
                : base(umbracoApplication)
            {
            }
<commit_msg>updates core boot manager tests<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Tests.TestHelpers;
using umbraco.interfaces;
using Umbraco.Core.Persistence;
using Umbraco.Core.Services;

namespace Umbraco.Tests.BootManagers
{
    [TestFixture]
    public class CoreBootManagerTests : BaseUmbracoConfigurationTest
    {

        private TestApp _testApp;

        [SetUp]
        public override void Initialize()
        {
            base.Initialize();
            _testApp = new TestApp();            
        }

        [TearDown]
        public override void TearDown()
        {
            base.TearDown();

            _testApp = null;            
        }

     
        /// <summary>
        /// test application using a CoreBootManager instance to boot
        /// </summary>
        public class TestApp : UmbracoApplicationBase
        {
            protected override IBootManager GetBootManager()
            {
                return new TestBootManager(this);
            }
        }

        /// <summary>
        /// Test boot manager to add a custom application event handler
        /// </summary>
        public class TestBootManager : CoreBootManager
        {
            public TestBootManager(UmbracoApplicationBase umbracoApplication)
                : base(umbracoApplication)
            {
            }

            /// <summary>
            /// Creates and assigns the application context singleton
            /// </summary>
            /// <param name="dbContext"></param>
            /// <param name="serviceContext"></param>
            protected override void CreateApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext)
            {
                base.CreateApplicationContext(dbContext, serviceContext);

                var dbContextMock = new Mock<DatabaseContext>(Mock.Of<IDatabaseFactory>(), Mock.Of<ILogger>(), Mock.Of<ISqlSyntaxProvider>(), "test");
                dbContextMock.Setup(x => x.CanConnect).Returns(true);
                ApplicationContext.DatabaseContext = dbContextMock.Object;
            }

{'fraction_non_alphanumeric': 0.08733434716489247, 'fraction_numerical': 0.0, 'mean_word_length': 2.0611702127659575, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2399230', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1153, 'n_words': 280}