public virtual void DatabaseSchemaCreation_Returns_DatabaseSchemaResult_Where_DetermineInstalledVersion_Is_4_7_0()
        {
            // Arrange
            var db = GetConfiguredDatabase();
            var schema = new DatabaseSchemaCreation(db);

            //Create db schema and data from old Total.sql file for Sql Ce
            string statements = GetDatabaseSpecificSqlScript();
            // replace block comments by whitespace
            statements = FindComments.Replace(statements, " ");
            // execute all non-empty statements
            foreach (string statement in statements.Split(";".ToCharArray()))
            {
                string rawStatement = statement.Replace("GO", "").Trim();
                if (rawStatement.Length > 0)
                    db.Execute(new Sql(rawStatement));
            }

            // Act
            var result = schema.ValidateSchema();

            // Assert
            var expected = new Version(4, 7, 0);
            Assert.AreEqual(expected, result.DetermineInstalledVersion());
        }
        public void DatabaseSchemaCreation_Produces_DatabaseSchemaResult_With_Zero_Errors()
        {
            // Arrange
            var db = DatabaseContext.Database;
            var schema = new DatabaseSchemaCreation(db);

            // Act
            var result = schema.ValidateSchema();

            // Assert
            Assert.That(result.Errors.Count, Is.EqualTo(0));
            Assert.AreEqual(result.DetermineInstalledVersion(), UmbracoVersion.Current);
        }
        public virtual void Initialize()
        {

            // Disable medium trust
            var transform = TransformWebConfig("Release");

            var assemblyPath = TestHelper.CurrentAssemblyDirectory;
            assemblyPath = Path.Combine(assemblyPath, @"..\..\..\Umbraco.Web.UI\");
            var webUiPath = Path.GetFullPath(new Uri(assemblyPath).LocalPath);

            var installedPackagesConfig = string.Format("{0}App_Data\\packages\\installed\\installedPackages.config", webUiPath);
            if (File.Exists(installedPackagesConfig))
                File.Delete(installedPackagesConfig);

            var databaseDataPath = string.Format(@"{0}\App_Data\Umbraco.sdf", webUiPath);
            var connectionString = string.Format(@"Data Source={0}", databaseDataPath);

            //Create the Sql CE database
            var engine = new SqlCeEngine(connectionString);
            if (File.Exists(databaseDataPath) == false)
                engine.CreateDatabase();

            SqlSyntaxContext.SqlSyntaxProvider = new SqlCeSyntaxProvider();

            _database = new UmbracoDatabase(connectionString, "System.Data.SqlServerCe.4.0");

            // First remove anything in the database
            var creation = new DatabaseSchemaCreation(_database);
            creation.UninstallDatabaseSchema();

            // Then populate it with fresh data
            _database.CreateDatabaseSchema(false);

            _database.Execute("UPDATE umbracoUser SET userName = '******', userPassword = '******', userEmail = 'none' WHERE id = 0"); // password: test

            // Recycle app pool so the new user can log in
            //var webConfigFilePath = string.Format(@"{0}\web.config", webUiPath);
            //File.SetLastWriteTime(webConfigFilePath, DateTime.Now);

            // Disable medium trust
            transform = TransformWebConfig("Release");

            Driver = new FirefoxDriver();
            BaseUrl = "http://localhost:61639/";
            _verificationErrors = new StringBuilder();
        }
示例#4
0
        internal DatabaseSchemaResult ValidateDatabaseSchema()
        {
            if (_configured == false || (string.IsNullOrEmpty(_connectionString) || string.IsNullOrEmpty(ProviderName)))
                return new DatabaseSchemaResult();

            if (_result == null)
            {
                var database = new UmbracoDatabase(_connectionString, ProviderName);
                var dbSchema = new DatabaseSchemaCreation(database);
                _result = dbSchema.ValidateSchema();
            }
            return _result;
        }