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()));
            }
        }
Beispiel #2
0
        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, Resolver);

                AssertAreEqualIgnoringWhitespacesAndCase(expectedMinimal, destination.ToString());
            }
        }
Beispiel #3
0
        public void GeneratesMinimalRequiredAppConfigForAlmostEmptySource()
        {
            using (var source = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"))
                using (var destination = new Utf8StringWriter())
                {
                    string expectedMinimal =
                        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                        "<configuration>" +
                        $"<runtime>{GcSettings}</runtime>" +
                        "</configuration>";

                    AppConfigGenerator.Generate(Job.Default, source, destination, Resolver);

                    AssertAreEqualIgnoringWhitespacesAndCase(expectedMinimal, destination.ToString());
                }
        }
Beispiel #4
0
        public void RewritesCutomRuntimeSettings()
        {
            const string customSettings =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                "<!--" +
                "commentsAreSupported" +
                "-->" +
                "<configuration>" +
                "<someConfig>withItsValue</someConfig>" +
                "<runtime><AppContextSwitchOverrides value=\"Switch.System.IO.UseLegacyPathHandling=false\"/></runtime>" +
                "</configuration>";

            using (var source = new StringReader(customSettings))
                using (var destination = new Utf8StringWriter())
                {
                    AppConfigGenerator.Generate(Job.Default, source, destination, Resolver);

                    AssertAreEqualIgnoringWhitespacesAndCase(customSettings, destination.ToString());
                }
        }
Beispiel #5
0
        public void RewritesCutomSettings()
        {
            const 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, Resolver);

                    AssertAreEqualIgnoringWhitespacesAndCase(customSettings, 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 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, Resolver);

                    AssertAreEqualIgnoringWhitespacesAndCase(customSettingsAndJit, destination.ToString());
                }
        }
Beispiel #8
0
        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());
                }
        }
Beispiel #9
0
        public void RewritesCutomAssemblyBindingRedirects()
        {
            const 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>";

            const 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, Resolver);

                    AssertAreEqualIgnoringWhitespacesAndCase(settingsWithBindingsAndJit, 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()));
            }
        }