示例#1
0
		public void CanOverrideDefaultLocation()
		{
			RegistrationSettingsProvider.SetProductName("FlowerUnitTest");
			var settingsProvider = new TestCrossPlatformSettingsProvider();
			settingsProvider.Initialize(null, null); // Seems to be what .NET does, despite warnings
			var dirPath = settingsProvider.UserConfigLocation;
			Assert.That(dirPath, Is.StringContaining("FlowerUnitTest"));
			Directory.CreateDirectory(dirPath);
			var filePath = Path.Combine(dirPath, TestCrossPlatformSettingsProvider.UserConfigFileName);
			using (var tempFile = new TempFile(filePath, true))
			{
				File.WriteAllText(filePath,
					@"<?xml version='1.0' encoding='utf-8'?>
<configuration>
    <userSettings>
        <Palaso.UI.WindowsForms.Registration.Registration>
            <setting name='Email' serializeAs='String'>
                <value>[email protected]</value>
            </setting>
        </Palaso.UI.WindowsForms.Registration.Registration>
    </userSettings>
</configuration>");

				var regSettings = Registration.Default;
				var email = regSettings.Email;
				Assert.That(email, Is.EqualTo("*****@*****.**"));
			}
		}
示例#2
0
        public void CanOverrideDefaultLocation()
        {
            string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SIL", "SettingsProviderTests");

            Directory.CreateDirectory(settingsPath);
            using (TemporaryFolder.TrackExisting(settingsPath))
            {
                RegistrationSettingsProvider.SetProductName("SettingsProviderTests");
                var settingsProvider = new TestCrossPlatformSettingsProvider();
                settingsProvider.Initialize(null, null);                 // Seems to be what .NET does, despite warnings
                string dirPath = settingsProvider.UserConfigLocation;
                Assert.That(dirPath, Is.StringContaining("SettingsProviderTests"));
                Directory.CreateDirectory(dirPath);
                string filePath = Path.Combine(dirPath, TestCrossPlatformSettingsProvider.UserConfigFileName);
                using (new TempFile(filePath, true))
                {
                    File.WriteAllText(filePath,
                                      @"<?xml version='1.0' encoding='utf-8'?>
<configuration>
	<userSettings>
		<SIL.Windows.Forms.Registration.Registration>
			<setting name='Email' serializeAs='String'>
				<value>[email protected]</value>
			</setting>
		</SIL.Windows.Forms.Registration.Registration>
	</userSettings>
</configuration>");

                    Registration.Registration regSettings = Registration.Registration.Default;
                    Assert.That(regSettings.Email, Is.EqualTo("*****@*****.**"));
                }
            }
        }