public void MergeResourceDictionaryPostaction_Failing()
        {
            var source     = Path.GetFullPath(@".\TestData\Merge\Style_fail.xaml");
            var postaction = Path.GetFullPath(@".\TestData\Merge\Style_fail_postaction.xaml");
            var expected   = File.ReadAllText(@".\TestData\Merge\Style_expected.xaml");

            GenContext.Current = this;
            var config = new MergeConfiguration(postaction, true);

            var mergeResourceDictionaryPostAction = new MergeResourceDictionaryPostAction(config);

            Exception ex = Assert.Throws <InvalidDataException>(() => mergeResourceDictionaryPostAction.Execute());

            Assert.Equal(string.Format(Resources.StringRes.FailedMergePostActionKeyAlreadyDefined, "PageTitleStyle"), ex.Message);
        }
        public void MergeResourceDictionaryPostaction_Failing()
        {
            var source     = Path.GetFullPath(@".\TestData\Merge\Style_fail.xaml");
            var postaction = Path.GetFullPath(@".\TestData\Merge\Style_fail_postaction.xaml");
            var expected   = File.ReadAllText(@".\TestData\Merge\Style_expected.xaml");

            GenContext.Current = this;
            var config = new MergeConfiguration(postaction, true);

            var mergeResourceDictionaryPostAction = new MergeResourceDictionaryPostAction(config);

            Exception ex = Assert.Throws <InvalidDataException>(() => mergeResourceDictionaryPostAction.Execute());

            Assert.Equal($"The style with key 'PageTitleStyle' is already defined with different value or elements in this file. Please review the styles to include the changes manually where required in your project.", ex.Message);
        }
示例#3
0
        public void MergeResourceDictionary_Execute()
        {
            var source     = Path.GetFullPath(@".\TestData\Merge\Style.xaml");
            var postaction = Path.GetFullPath(@".\TestData\Merge\Style_postaction.xaml");
            var expected   = File.ReadAllText(@".\TestData\Merge\Style_expected.xaml").Replace("\r\n", string.Empty).Replace("\n", string.Empty);

            var config = new MergeConfiguration(postaction, true);

            var mergeResourceDictionaryPostAction = new MergeResourceDictionaryPostAction("Test", config);

            mergeResourceDictionaryPostAction.Execute();

            var result = File.ReadAllText(source).Replace("\r\n", string.Empty).Replace("\n", string.Empty);

            Assert.Equal(result, expected);
        }
示例#4
0
        public void MergeResourceDictionaryPostaction_Failing()
        {
            var source     = Path.GetFullPath(@".\TestData\Merge\Style_fail.xaml");
            var postaction = Path.GetFullPath(@".\TestData\Merge\Style_fail_postaction.xaml");
            var expected   = File.ReadAllText(@".\TestData\Merge\Style_expected.xaml");

            GenContext.Current = this;
            var config = new MergeConfiguration(postaction, true);

            var mergeResourceDictionaryPostAction = new MergeResourceDictionaryPostAction("TestTemplate", config);

            Exception ex = Assert.Throws <Exception>(() => mergeResourceDictionaryPostAction.Execute());

            Assert.NotNull(ex.InnerException);
            Assert.Equal(typeof(System.IO.InvalidDataException), ex.InnerException.GetType());
            Assert.Equal(string.Format(Resources.StringRes.PostActionException, "Microsoft.Templates.Core.PostActions.Catalog.Merge.MergeResourceDictionaryPostAction", "TestTemplate"), ex.Message);
        }
示例#5
0
        static int Main(string[] args)
        {
            if (args.Length != 3)
            {
                System.Console.Error.WriteLine("Usage: <config> <inputdir> <outputdir>");
                return(1);
            }

            var configPath  = args[0];
            var inputDir    = args[1];
            var outputDir   = args[2];
            var mergeConfig = MergeConfiguration.LoadFile(configPath);

            if (Directory.Exists(outputDir))
            {
                Directory.Delete(outputDir, true);
            }
            return(NugetPackageMerger.Merge(inputDir, outputDir, mergeConfig, new NumergeConsoleLogger()) ? 0 : 2);
        }
        public void MergeResourceDictionary_Execute()
        {
            var source     = Path.GetFullPath(@".\TestData\Merge\Style.xaml");
            var postaction = Path.GetFullPath(@".\TestData\Merge\Style_postaction.xaml");
            var expected   = File.ReadAllText(@".\TestData\Merge\Style_expected.xaml").Replace("\r\n", string.Empty).Replace("\n", string.Empty);

            var config = new MergeConfiguration(postaction, new XmlStyleProvider(), true);

            GenContext.Current = new TestContextProvider()
            {
                GenerationOutputPath = Environment.CurrentDirectory,
                DestinationPath      = Environment.CurrentDirectory,
            };

            var mergeResourceDictionaryPostAction = new MergeResourceDictionaryPostAction("Test", config);

            mergeResourceDictionaryPostAction.Execute();

            var result = File.ReadAllText(source).Replace("\r\n", string.Empty).Replace("\n", string.Empty);

            Assert.Equal(result, expected);
        }