public void given_versionOne_specific_settings_are_saved_in_the_file() { const string userName = "******"; const string password = "******"; const string v1Url = "https://www14.v1host.com/v1sdktesting/"; const string tfsurl = "http://vsts2012:8080/tfs/DefaultCollection/"; const string tfsListenerUrl = "http://localhost:5050/servicesRus.svc"; const string tfsuser = "******"; const string tfspass = "******"; const string configUrl = "http://locahost:8181/"; const string baseListenerUrl = "http://localhost:9090/"; const bool useWindowsSecurity = false; before = () => { _target = new ConfigurationProvider(); _target.ClearAllSettings(); SettingsFileAdapter.SaveSettings(new Dictionary <string, string>() { { AppSettingKeys.VersionOneUserName, userName }, { AppSettingKeys.VersionOnePassword, password }, { AppSettingKeys.VersionOneUrl, v1Url }, { AppSettingKeys.IsWindowsIntegratedSecurity, useWindowsSecurity.ToString() }, { AppSettingKeys.TfsUrl, tfsurl.ToString() }, { AppSettingKeys.TfsListenerUrl, tfsListenerUrl.ToString() }, { AppSettingKeys.TfsUserName, tfsuser }, { AppSettingKeys.TfsPassword, tfspass }, { AppSettingKeys.ConfigurationUrl, configUrl }, { AppSettingKeys.BaseListenerUrl, baseListenerUrl } }, Paths.ConfigurationDirectory, FileName); }; context["when i retrieve versionone specific settings"] = () => { it["then the expected settings are returned"] = () => { _target = new ConfigurationProvider(); _target.VersionOneUserName.should_be(userName); _target.VersionOnePassword.should_be(password); _target.VersionOneUrl.ToString().should_be(v1Url); _target.IsWindowsIntegratedSecurity.should_be(useWindowsSecurity); _target.TfsUrl.ToString().should_be(tfsurl); _target.TfsListenerUrl.ToString().should_be(tfsListenerUrl); _target.TfsUserName.should_be(tfsuser); _target.TfsPassword.should_be(tfspass); _target.ConfigurationUrl.ToString().should_be(configUrl); _target.BaseListenerUrl.ToString().should_be(baseListenerUrl); }; }; }
public void given_settings_are_being_saved_to_a_file() { context["when a dictionary of strings is saved to the settings file"] = () => { var directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "V1TFSServerTests"); const string fileName = "settings.ini"; var settings = new Dictionary <string, string> { { "Setting1", "Value1" }, { "Setting2", "Value2" } }; var qualifiedPath = Path.Combine(directory, fileName); if (File.Exists(qualifiedPath)) { File.Delete(qualifiedPath); } SettingsFileAdapter.SaveSettings(settings, directory, fileName); it["then the file exists"] = () => File.Exists(qualifiedPath).should_be(true); it["and the expected settings are present"] = () => { var retrievedSettings = new Dictionary <string, string>(); using (var reader = new StreamReader(qualifiedPath)) { string commaDelimitedLine; while ((commaDelimitedLine = reader.ReadLine()) != null) { var parsedValues = commaDelimitedLine.Split(Seperators.Primary); retrievedSettings.Add(parsedValues[0], parsedValues[1]); } } retrievedSettings.ContainsKey("Setting1").should_be(true); retrievedSettings.ContainsKey("Setting2").should_be(true); retrievedSettings["Setting1"].Trim().should_be("Value1"); retrievedSettings["Setting2"].Trim().should_be("Value2"); }; }; }
public void given_versionOne_specific_settings_are_saved_in_the_web_config() { const string proxyIsEnabled = "false"; const string proxyDomain = "DOMAIN5000"; const string proxyUrl = "http://myProxyUrl:9192/login/"; const string proxyUserName = "******"; const string proxyPassword = "******"; before = () => { var settings = new Dictionary <string, string>() { { AppSettingKeys.ProxyIsEnabled, proxyIsEnabled }, { AppSettingKeys.ProxyDomain, proxyDomain }, { AppSettingKeys.ProxyUrl, proxyUrl }, { AppSettingKeys.ProxyUserName, proxyUserName }, { AppSettingKeys.ProxyPassword, proxyPassword } }; _target = new ProxySettingsProvider(settings); _defaults = new DefaultProxySettingsProvider(); new ConfigurationProvider().ClearAllSettings(); SettingsFileAdapter.SaveSettings(settings, Paths.ConfigurationDirectory, Paths.ConfigurationFileName); }; context["when i retrieve versionone specific settings"] = () => { it["then the saved values are returned"] = () => { _target.ProxyIsEnabled.should_be(bool.Parse(proxyIsEnabled)); _target.Domain.should_be(proxyDomain); _target.Uri.ToString().should_be(proxyUrl.ToLower()); //uri object stores url string in all lowercase _target.Username.should_be(proxyUserName); _target.Password.should_be(proxyPassword); }; }; }