本文整理汇总了C#中Console.BuildConfigFilesFromMaster方法的典型用法代码示例。如果您正苦于以下问题:C# Console.BuildConfigFilesFromMaster方法的具体用法?C# Console.BuildConfigFilesFromMaster怎么用?C# Console.BuildConfigFilesFromMaster使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Console
的用法示例。
在下文中一共展示了Console.BuildConfigFilesFromMaster方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCreateConfigFileForNamedEnv
public void ShouldCreateConfigFileForNamedEnv()
{
var masterConfig = new XElement("stuff",
new XAttribute(Console.BuildConfigForAttribute, "dev, systest, uat"),
new XElement("dome", new XAttribute("name", "7")),
new XElement("hill", new XElement("speed", new XAttribute(ConfigurationGenerator.ForEnvironmentsAttribute, "systest"), "some text")),
new XElement("development", new XAttribute(ConfigurationGenerator.ForEnvironmentsAttribute, Console.DefaultEnvironment), 4));
var config = new XElement("stuff",
new XElement("dome", new XAttribute("name", "7")),
new XElement("hill", new XElement("speed", "some text")));
var diskAccessMock = new Mock<IXmlLoaderSaver>();
const string masterFileName = "app.master.config";
diskAccessMock.Setup(ls => ls.Load(masterFileName)).Returns(new XDocument(masterConfig));
XDocument exportedConfig = null;
diskAccessMock.Setup(ls => ls.Save(It.IsAny<XDocument>(), "the.config")).Callback<XDocument, string>((doc, fn) => exportedConfig = doc);
var console = new Console();
console.BuildConfigFilesFromMaster(masterFileName, "the.config", "systest", diskAccessMock.Object);
Assert.That(exportedConfig, Is.Not.Null);
Assert.AreEqual(config.ToString(), exportedConfig.ToString());
}
示例2: ShouldLoadMasterConfigAndSaveOneForEachEnvironment
public void ShouldLoadMasterConfigAndSaveOneForEachEnvironment()
{
XElement config = new XElement("stuff",
new XAttribute(Console.BuildConfigForAttribute, "dev, systest1, systest2"),
new XElement("dome", new XAttribute("name", "7")),
new XElement("hill", new XElement("speed", new XAttribute(ConfigurationGenerator.ForEnvironmentsAttribute, "systest1"), "some text")),
new XElement("development", new XAttribute(ConfigurationGenerator.ForEnvironmentsAttribute, Console.DefaultEnvironment), 4));
XElement expectedDev = new XElement("stuff",
new XElement("dome", new XAttribute("name", "7")),
new XElement("hill"),
new XElement("development", 4));
XElement expectedSystest1 = new XElement("stuff",
new XElement("dome", new XAttribute("name", "7")),
new XElement("hill", new XElement("speed", "some text")));
XElement expectedSystest2 = new XElement("stuff",
new XElement("dome", new XAttribute("name", "7")),
new XElement("hill"));
Mock<IXmlLoaderSaver> diskAccessMock = new Mock<IXmlLoaderSaver>();
string masterFileName = "app.master.config";
diskAccessMock.Setup(ls => ls.Load(masterFileName)).Returns(new XDocument(config));
XDocument devDoc = null, systest1Doc = null, systest2Doc = null;
diskAccessMock.Setup(ls => ls.Save(It.IsAny<XDocument>(), "app.config")).Callback<XDocument, string>((doc, fn) => devDoc = doc);
diskAccessMock.Setup(ls => ls.Save(It.IsAny<XDocument>(), "app.systest1.config")).Callback<XDocument, string>((doc, fn) => systest1Doc = doc);
diskAccessMock.Setup(ls => ls.Save(It.IsAny<XDocument>(), "app.systest2.config")).Callback<XDocument, string>((doc, fn) => systest2Doc = doc);
var console = new Console();
console.BuildConfigFilesFromMaster(masterFileName, diskAccessMock.Object);
Assert.AreEqual(expectedDev.ToString(), devDoc.ToString());
Assert.AreEqual(expectedSystest1.ToString(), systest1Doc.ToString());
Assert.AreEqual(expectedSystest2.ToString(), systest2Doc.ToString());
}