Esempio n. 1
0
        public void WriteTemporaryConfigurationFile_ThrowsIfApplicationBaseDirectoryMissingButRequested()
        {
            HostSetup setup = new HostSetup();

            setup.ConfigurationFileLocation = ConfigurationFileLocation.AppBase;

            Assert.Throws <InvalidOperationException>(() => setup.WriteTemporaryConfigurationFile());
        }
Esempio n. 2
0
        public void WriteTemporaryConfigurationFile_ReturnsNullWhenNone()
        {
            HostSetup setup = new HostSetup();

            setup.ConfigurationFileLocation = ConfigurationFileLocation.None;

            Assert.IsNull(setup.WriteTemporaryConfigurationFile());
        }
Esempio n. 3
0
        public void WriteTemporaryConfigurationFile_UsesTempFolderByDefault()
        {
            HostSetup setup = new HostSetup();

            setup.ConfigurationFileLocation = ConfigurationFileLocation.Temp;

            string path = setup.WriteTemporaryConfigurationFile();

            try
            {
                Assert.AreEqual(SpecialPathPolicy.For("Hosting").GetTempDirectory().FullName, Path.GetDirectoryName(path));
                Assert.Contains(File.ReadAllText(path), "<configuration>");
            }
            finally
            {
                File.Delete(path);
            }
        }
Esempio n. 4
0
        public void WriteTemporaryConfigurationFile_UsesApplicationBaseDirectoryWhenRequested()
        {
            HostSetup setup = new HostSetup();

            setup.ApplicationBaseDirectory  = AppDomain.CurrentDomain.BaseDirectory;
            setup.ConfigurationFileLocation = ConfigurationFileLocation.AppBase;

            string path = setup.WriteTemporaryConfigurationFile();

            try
            {
                Assert.AreEqual(Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory), Path.GetDirectoryName(path));
                Assert.EndsWith(path, ".tmp.config");
                Assert.Contains(File.ReadAllText(path), "<configuration>");
            }
            finally
            {
                File.Delete(path);
            }
        }