public void WriteTemporaryConfigurationFile_ThrowsIfApplicationBaseDirectoryMissingButRequested() { HostSetup setup = new HostSetup(); setup.ConfigurationFileLocation = ConfigurationFileLocation.AppBase; Assert.Throws <InvalidOperationException>(() => setup.WriteTemporaryConfigurationFile()); }
public void WriteTemporaryConfigurationFile_ReturnsNullWhenNone() { HostSetup setup = new HostSetup(); setup.ConfigurationFileLocation = ConfigurationFileLocation.None; Assert.IsNull(setup.WriteTemporaryConfigurationFile()); }
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); } }
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); } }