Пример #1
0
 private static void UpdateDataBases(User user, Options options)
 {
     foreach (var testDatabase in options.TestDatabases.Cast<TestDatabase>()) {
         var suffix = user.Name != null ? "_" + user.Name : null;
         testDatabase.DBName = testDatabase.DefaultDBName() + suffix;
     }
 }
Пример #2
0
 private static void UpdateTestFileCore(string fileName, User user, Options options)
 {
     var allText = File.ReadAllText(fileName);
     foreach (var testDatabase in options.TestDatabases.Cast<TestDatabase>()){
         var suffix = user.Name != null ? "_" + user.Name : null;
         allText = Regex.Replace(allText, @"(" +testDatabase.DefaultDBName()+ @")(_[^\s]*)?", "$1"+suffix, RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Multiline);
     }
     File.WriteAllText(fileName, allText);
 }
Пример #3
0
 private static Queue<User> CreateUserQueue(RegistryKey registryKey, string userNames)
 {
     string[] passwords = ((string)registryKey.GetValue("Password")).Split(';');
     var userQueue = new Queue<User>();
     for (int i = 0; i < userNames.Split(';').Length; i++) {
         string userName = userNames.Split(';')[i];
         var user = new User { Name = userName, Password = passwords[i] };
         userQueue.Enqueue(user);
     }
     return userQueue;
 }
Пример #4
0
 public static void UpdateAdditionalApps(EasyTest easyTest, Options options, User user)
 {
     var additionalApps =options.Applications.Cast<TestApplication>()
             .SelectMany(application => application.AdditionalAttributes)
             .Where(attribute => attribute.LocalName == "AdditionalApplications")
             .Select(attribute => attribute.Value);
     foreach (var additionalApp in additionalApps){
         var path = Path.Combine(Path.GetDirectoryName(additionalApp) + "", Path.GetFileName(additionalApp) + ".config");
         var document = XDocument.Load(path);
         UpdateAppConfigCore(easyTest, options, user, document);
         document.Save(path);
     }
 }
Пример #5
0
 private static void UpdateAppBinAlias(User user, Options options)
 {
     foreach (var alias in options.Aliases.Cast<TestAlias>().Where(@alias => alias.ContainsAppPath())) {
         alias.Value = alias.UpdateAppPath(user.Name);
     }
 }
Пример #6
0
 private static void UpdateAppConfig(EasyTest easyTest, Options options, TestAlias alias, User user)
 {
     var keyValuePair = LoadAppConfig(alias, options.Applications);
     if (File.Exists(keyValuePair.Value)) {
         var document = keyValuePair.Key;
         UpdateAppConfigCore(easyTest, options, user, document);
         document.Save(keyValuePair.Value);
     }
 }
Пример #7
0
 private static void UpdateConnectionStrings(User user, Options options, XDocument document)
 {
     foreach (TestDatabase testDatabase in options.TestDatabases) {
         var database = testDatabase.DefaultDBName();
         var connectionStrings = document.Descendants("connectionStrings").SelectMany(element => element.Descendants())
             .Where(element => element.Attribute("connectionString").Value.ToLowerInvariant().Contains(database.ToLowerInvariant())).Select(element
                 => element.Attribute("connectionString"));
         foreach (var connectionString in connectionStrings){
             string userNameSuffix = user.Name!=null?"_" + user.Name:null;
             connectionString.Value = Regex.Replace(connectionString.Value,
                 @"(.*)(" + database + @"[^;""\s]*)(.*)", "$1" + database + userNameSuffix + "$3",
                 RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Multiline);
         }
     }
 }
Пример #8
0
 private static void UpdateAppConfigCore(EasyTest easyTest, Options options, User user, XDocument document)
 {
     UpdatePort(easyTest.WinPort, document);
     UpdateConnectionStrings(user, options, document);
 }