public async Task <ISmokeTestSettings> GetSmokeTestSettings()
        {
            //does the file exist?
            if (File.Exists(_fileLocation))
            {
                await _logger.ReportInfo($"Loading settings from {_fileLocation}", new[] { "settings" });

                var task = Task.Run(() => File.ReadAllText(_fileLocation));

                var contents = await task;

                var deser = JsonConvert.DeserializeObject <SmokeTestConnectionStorage>(contents);

                if (deser == null)
                {
                    throw new SerializationException("Could not deserialize from " + _fileLocation);
                }

                return(new SmokeTestConnections(deser));
            }

            await _logger.ReportInfo("Cannot load settings, retrieving from backup", new[] { "settings" });

            var settings = await _backupFactory.GetSmokeTestSettings();

            var formatted = new SmokeTestConnectionStorage(settings);

            if (_saveIfNotPresent)
            {
                await _logger.ReportInfo("Saving connection settings to " + _fileLocation, new [] { "save", "settings" });
                await SaveSettings(formatted);
            }

            return(new SmokeTestConnections(formatted));
        }
 public SmokeTestConnections(SmokeTestConnectionStorage source)
 {
     AppsUrl   = source.AppsUrl;
     UserLogin = new UserLogin {
         UserName = source.UserName, Password = source.UserPassword
     };
     MaxPromotionWaitTime = source.MaxPromotionWaitTime;
     TestRunPollTime      = source.TestRunPollTime;
     AdminUserLogin       = new UserLogin {
         UserName = source.AdminUserName, Password = source.AdminUserPassword
     };
     IntegrationTestResourcesDirectory = source.IntegrationTestResourcesDirectory;
     RepositoryServer             = source.RepositoryServer;
     AdminTenantAlias             = source.AdminTenantAlias;
     RootUrl                      = source.RootUrl;
     EnvironmentFeaturesAvailable = new EnvironmentFeaturesAvailableS
     {
         IsExternalUserStore = source.IsExternalUserStore,
         IsMultipleNodes     = source.IsMultipleNodes
     };
     EnvironmentInformation = new EnvironmentInformationS
     {
         IsEUS        = source.IsExternalUserStore,
         EUSGroupId   = source.EUSGroupId,
         EUSGroupName = source.EUSGroupName
     };
 }
        private Task SaveSettings(SmokeTestConnectionStorage settings)
        {
            var write = JsonConvert.SerializeObject(settings);

            var writeTask = Task.Run(() => File.WriteAllText(_fileLocation, write));

            return(writeTask);
        }