当前位置: 首页>>代码示例>>C#>>正文


C# Console.BuildConfigFilesFromMaster方法代码示例

本文整理汇总了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());
        }
开发者ID:refractalize,项目名称:confgen,代码行数:26,代码来源:ConsoleTest.cs

示例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());
        }
开发者ID:refractalize,项目名称:confgen,代码行数:36,代码来源:ConsoleTest.cs


注:本文中的Console.BuildConfigFilesFromMaster方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。