Пример #1
0
 private void InitializeSettings(DeployerConfigurationSection confSection)
 {
     Credentials = new Credentials(
         confSection.Settings.Credentials.Domain,
         confSection.Settings.Credentials.Login,
         confSection.Settings.Credentials.Password);
     Survey = new Survey(_context.UriName, _context.DatabaseName ?? _context.UriName, _context.Mode);
     var surveyDir = Path.Combine(confSection.Settings.Paths.Surveys, _context.DirectoryName ?? _context.UriName);
     SurveyPath = new SurveyPaths(surveyDir, () => Path.Combine(surveyDir, "bin"));
     PackagePaths = new PackagePaths(
         Path.Combine(confSection.Settings.Paths.Uploads, _context.UriName + ".zip"),
         Path.Combine(confSection.Settings.Paths.Backups, _context.UriName + ".zip"));
     CommonPaths = new CommonPaths(
         confSection.Settings.Paths.Surveys,
         confSection.Settings.Paths.Uploads,
         confSection.Settings.Paths.Backups);
     DbScriptsPaths = new DbScriptsPaths(
         confSection.Settings.ScriptsPaths.DbCreate,
         confSection.Settings.ScriptsPaths.DbValidate,
         confSection.Settings.ScriptsPaths.DbDelete);
     Templates = new TemplatesPaths(
         confSection.Settings.Templates.ConnectionStrings,
         confSection.Settings.Paths.AdditionalResources.Bins);
     ConnectionStrings = new ConnectionStrings(
         ConfigurationManager.ConnectionStrings["master"].ConnectionString,
         ConfigurationManager.ConnectionStrings["deployer"].ConnectionString);
     IIS = new IISInfo(
         confSection.Settings.IIS.Version,
         confSection.Settings.IIS.Address,
         confSection.Settings.IIS.ApplicationPool,
         confSection.Settings.IIS.DirsWithIISAccess == null
             ? new List<KeyValuePair<string, string>>()
             : confSection.Settings.IIS.DirsWithIISAccess.Cast<DirElement>()
                 .Select(dir => new KeyValuePair<string, string>(dir.Name, dir.User)));
 }
Пример #2
0
        private IConf CreateConfForPackage(string packageName)
        {
            var confSection = DeployerConfigurationSection.Instance;

            var pathToSurvey = Path.Combine(confSection.Settings.Paths.Surveys, _surveyDir);
            var survey = new Survey(null, _surveyDir, default(DeployMode));
            var surveyPaths = new SurveyPaths(pathToSurvey, () => Path.Combine(pathToSurvey, "bin"));
            var packagePaths = new PackagePaths(Path.Combine(confSection.Settings.Paths.Uploads, packageName + ".zip"),
                                                Path.Combine(confSection.Settings.Paths.Backups, packageName + ".zip"));
            var commonPaths = new CommonPaths(confSection.Settings.Paths.Surveys, confSection.Settings.Paths.Uploads,
                                              confSection.Settings.Paths.Backups);
            var templates = new TemplatesPaths(confSection.Settings.Templates.ConnectionStrings, confSection.Settings.Paths.AdditionalResources.Bins);
            var iisManager = new Mock<IIISManager>();
            iisManager.Setup(m => m.SurveyPath).Returns(surveyPaths.Survey);

            var mockedConf = new Mock<IConf>();
            mockedConf.Setup(s => s.Survey).Returns(survey);
            mockedConf.Setup(s => s.SurveyPath).Returns(surveyPaths);
            mockedConf.Setup(s => s.CommonPaths).Returns(commonPaths);
            mockedConf.Setup(s => s.PackagePaths).Returns(packagePaths);
            mockedConf.Setup(s => s.Templates).Returns(templates);
            mockedConf.Setup(s => s.PackageManager).Returns(new PackageManager());
            mockedConf.Setup(s => s.IISManager).Returns(iisManager.Object);
            mockedConf.Setup(s => s.IIS).Returns(new IISInfo(null, null, null, confSection.Settings.IIS.DirsWithIISAccess.Cast<DirElement>()
                .Select(dir => new KeyValuePair<string, string>(dir.Name, dir.User))));

            return mockedConf.Object;
        }