public void ParseDeploymentInfo()
        {
            IDeploymentInfo deploymentInfo;

            using(Stream resourceStream = 
                Assembly.GetExecutingAssembly().GetManifestResourceStream("octalforty.Wizardby.Tests.Resources.Database.wdi"))
            {
                DeploymentInfoParser deploymentInfoParser = new DeploymentInfoParser();
                deploymentInfo = deploymentInfoParser.ParseDeploymentInfo(new StreamReader(resourceStream, Encoding.UTF8));
            } // using

            Assert.AreEqual(2, deploymentInfo.Environments.Count);
            Assert.AreEqual("development", deploymentInfo.Environments[0].Name);
            Assert.AreEqual("staging", deploymentInfo.Environments[1].Name);
            Assert.AreEqual("sqlserver", deploymentInfo.Environments[0].Properties["platform"]);
        }
        protected IDbPlatform ResolveDbPlatform(MigrationParameters parameters)
        {
            IDbPlatform dbPlatform;
            if (!string.IsNullOrEmpty(parameters.Environment) ||
               (string.IsNullOrEmpty(parameters.ConnectionString) || string.IsNullOrEmpty(parameters.PlatformAlias)))
            {
                //
                // Environment name defaults to "development".
                if (string.IsNullOrEmpty(parameters.Environment))
                    parameters.Environment = DefaultEnvironmentName;

                string databaseWdiFilePath = Path.Combine(Directory.GetCurrentDirectory(), "database.wdi");
                if (!File.Exists(databaseWdiFilePath))
                    throw new MigrationException(string.Format(Resources.CouldNotFindDatabaseWdi, Directory.GetCurrentDirectory()));

                using(StreamReader streamReader = new StreamReader(databaseWdiFilePath))
                {
                    DeploymentInfoParser deploymentInfoParser = new DeploymentInfoParser();

                    IDeploymentInfo deploymentInfo = deploymentInfoParser.ParseDeploymentInfo(streamReader);
                    
                    IEnvironment environment = GetEnvironment(parameters, deploymentInfo);
                    ServiceProvider.RegisterService(environment);

                    if(string.IsNullOrEmpty(parameters.PlatformAlias))
                        parameters.PlatformAlias = environment.Properties["platform"];
                    
                    dbPlatform = ServiceProvider.GetService<DbPlatformRegistry>().ResolvePlatform(parameters.PlatformAlias);

                    EnsurePlatformResolved(parameters, dbPlatform);

                    //
                    // Build connection string
                    IDbConnectionStringBuilder connectionStringBuilder = dbPlatform.CreateConnectionStringBuilder();
                    foreach (string key in environment.Properties.AllKeys)
                    {
                        connectionStringBuilder.AppendKeyValuePair(key, environment.Properties[key]);
                    } // foreach

                    parameters.ConnectionString = connectionStringBuilder.ToString();
                } // using
            } // if
            else
            {
                dbPlatform = ServiceProvider.GetService<DbPlatformRegistry>().ResolvePlatform(parameters.PlatformAlias);
                EnsurePlatformResolved(parameters, dbPlatform);
            } // else

            ServiceProvider.RegisterService(dbPlatform);

            return dbPlatform;
        }