public void WriteToReencodesAccordingToTextWriter() { StringWriter writer = new StringWriter(); Assert.AreEqual(Encoding.Unicode.EncodingName, writer.Encoding.EncodingName); HostConfiguration config = new HostConfiguration(); config.WriteTo(writer); Assert.Contains(writer.ToString(), writer.Encoding.WebName); }
public void WriteToReencodesAccordingToTextWriter_WhenConfigurationXmlContainsDifferentEncoding() { StringWriter writer = new StringWriter(); Assert.AreEqual(Encoding.Unicode.EncodingName, writer.Encoding.EncodingName); HostConfiguration config = new HostConfiguration(); config.ConfigurationXml = "<?xml version=\"1.0\" encoding=\"utf-32\"?><configuration />"; config.WriteTo(writer); Assert.Contains(writer.ToString(), writer.Encoding.WebName); }
public void WriteToFile() { HostConfiguration config = new HostConfiguration(); string path = SpecialPathPolicy.For<HostConfigurationTest>().CreateTempFileWithUniqueName().FullName; try { config.WriteToFile(path); Assert.Contains(File.ReadAllText(path), "<configuration>"); } finally { File.Delete(path); } }
/// <summary> /// Creates a copy of the host configuration information. /// </summary> /// <returns>The copy.</returns> public HostConfiguration Copy() { var copy = new HostConfiguration(); copy.assertUiEnabled = assertUiEnabled; copy.configurationXml = configurationXml; copy.legacyUnhandledExceptionPolicyEnabled = legacyUnhandledExceptionPolicyEnabled; copy.loadFromRemoteSources = loadFromRemoteSources; copy.remotingCustomErrorsEnabled = remotingCustomErrorsEnabled; copy.supportedRuntimeVersions.AddRange(supportedRuntimeVersions); foreach (AssemblyDependency dependency in assemblyDependencies) { copy.assemblyDependencies.Add(dependency.Copy()); } foreach (AssemblyQualification qualification in assemblyQualifications) { copy.assemblyQualifications.Add(qualification.Copy()); } return(copy); }
public void WriteToFileThrowsIfPathIsNull() { HostConfiguration config = new HostConfiguration(); Assert.Throws<ArgumentNullException>(() => config.WriteToFile(null)); }
public void WriteToThrowsIfTextWriterIsNull() { HostConfiguration config = new HostConfiguration(); Assert.Throws<ArgumentNullException>(() => config.WriteTo(null)); }
/// <summary> /// Creates a copy of the host configuration information. /// </summary> /// <returns>The copy.</returns> public HostConfiguration Copy() { var copy = new HostConfiguration(); copy.assertUiEnabled = assertUiEnabled; copy.configurationXml = configurationXml; copy.legacyUnhandledExceptionPolicyEnabled = legacyUnhandledExceptionPolicyEnabled; copy.loadFromRemoteSources = loadFromRemoteSources; copy.remotingCustomErrorsEnabled = remotingCustomErrorsEnabled; copy.supportedRuntimeVersions.AddRange(supportedRuntimeVersions); foreach (AssemblyDependency dependency in assemblyDependencies) copy.assemblyDependencies.Add(dependency.Copy()); foreach (AssemblyQualification qualification in assemblyQualifications) copy.assemblyQualifications.Add(qualification.Copy()); return copy; }