public void GeneratesMinimalRequiredAppConfigForEmptySource() { using (var destination = new Utf8StringWriter()) { const string expectedMinimal = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<configuration>" + "<runtime/>" + "</configuration>"; AppConfigGenerator.Generate(Job.Default, TextReader.Null, destination); Assert.True(AreEqualIgnoringWhitespacesAndCase(expectedMinimal, destination.ToString())); } }
public void GeneratesRightJitSettings(Jit jit, string expectedRuntimeNode) { string customSettings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<configuration>" + "<someConfig>withItsValue</someConfig>" + "</configuration>"; string customSettingsAndJit = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<configuration>" + "<someConfig>withItsValue</someConfig>" + expectedRuntimeNode + "</configuration>" + Environment.NewLine; using (var source = new StringReader(customSettings)) using (var destination = new Utf8StringWriter()) { AppConfigGenerator.Generate(Job.Default.With(jit), source, destination); Assert.True(AreEqualIgnoringWhitespacesAndCase(customSettingsAndJit, destination.ToString())); } }
public void RemovesStartupSettingsForPrivateBuildsOfClr() { const string input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<configuration>" + "<startup><supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.6.1\" /></startup>" + "</configuration>"; string withoutStartup = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<configuration>" + "<runtime/>" + "</configuration>" + Environment.NewLine; using (var source = new StringReader(input)) using (var destination = new Utf8StringWriter()) { AppConfigGenerator.Generate(new Job { Environment = { Runtime = ClrRuntime.CreateForLocalFullNetFrameworkBuild(version: "4.0") } }.Freeze(), source, destination, Resolver); AssertAreEqualIgnoringWhitespacesAndCase(withoutStartup, destination.ToString()); } }
public void RewritesCutomAssemblyBindingRedirects() { string settingsWithBindings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<configuration>" + "<runtime>" + "<assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">" + "<dependentAssembly>" + "<assemblyIdentity name=\"System.Runtime\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" />" + "<bindingRedirect oldVersion=\"0.0.0.0-4.0.20.0\" newVersion=\"4.0.20.0\" />" + "</dependentAssembly>" + "</assemblyBinding>" + "</runtime>" + "</configuration>"; string settingsWithBindingsAndJit = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<configuration>" + "<runtime>" + "<assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">" + "<dependentAssembly>" + "<assemblyIdentity name=\"System.Runtime\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" />" + "<bindingRedirect oldVersion=\"0.0.0.0-4.0.20.0\" newVersion=\"4.0.20.0\" />" + "</dependentAssembly>" + "</assemblyBinding>" + "<useLegacyJit enabled =\"0\" />" + "</runtime>" + "</configuration>"; using (var source = new StringReader(settingsWithBindings)) using (var destination = new Utf8StringWriter()) { AppConfigGenerator.Generate(Job.RyuJitX64, source, destination); Assert.True(AreEqualIgnoringWhitespacesAndCase(settingsWithBindingsAndJit, destination.ToString())); } }
public void RewritesCutomSettings() { string customSettings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<!--" + "commentsAreSupported" + "-->" + "<configuration>" + "<someConfig>withItsValue</someConfig>" + "<runtime/>" + "</configuration>"; using (var source = new StringReader(customSettings)) using (var destination = new Utf8StringWriter()) { AppConfigGenerator.Generate(Job.Default, source, destination); Assert.True(AreEqualIgnoringWhitespacesAndCase(customSettings, destination.ToString())); } }