public static NewItemFileViewModel WarningFile(FailedMergePostActionInfo file)
 {
     return(new NewItemFileViewModel(FileStatus.WarningFile, file.FailedFileName, file.FailedFilePath, string.Empty, AsUserFriendlyPostAction)
     {
         Description = file.Description,
     });
 }
 public static NewItemFileViewModel ConflictingStylesFile(FailedMergePostActionInfo file)
 {
     return(new NewItemFileViewModel(FileStatus.ConflictingStylesFile, file.FailedFileName, file.FilePath, string.Empty, AsUserFriendlyPostAction)
     {
         FailedPostaction = file.FailedFilePath,
     });
 }
Ejemplo n.º 3
0
 public static NewItemFileViewModel ConflictingStylesFile(FailedMergePostActionInfo file)
 {
     return(new NewItemFileViewModel(FileStatus.ConflictingStylesFile, file.FileName, AsUserFriendlyPostAction)
     {
         FailedPostaction = Path.Combine(GenContext.Current.OutputPath, $"{file.FileName.Replace(".xaml", string.Empty)}_failedpostaction.xaml"),
     });
 }
        public void MergePostAction_Execute_LineNotFound_NoError()
        {
            var templateName    = "Test";
            var sourceFile      = Path.GetFullPath(@".\TestData\temp\Source_fail.cs");
            var mergeFile       = Path.GetFullPath(@".\TestData\temp\Source_fail_postaction.cs");
            var outputPath      = Path.GetFullPath(@".\TestData\temp");
            var destinationPath = Path.GetFullPath(@".\Destination\Project");

            Directory.CreateDirectory(outputPath);
            File.Copy(Path.Combine(Environment.CurrentDirectory, $"TestData\\Merge\\Source_fail.cs"), sourceFile, true);
            File.Copy(Path.Combine(Environment.CurrentDirectory, $"TestData\\Merge\\Source_fail_postaction.cs"), mergeFile, true);

            GenContext.Current = new FakeContextProvider()
            {
                GenerationOutputPath = outputPath,
                DestinationPath      = destinationPath,
            };

            var mergePostAction = new MergePostAction(templateName, new MergeConfiguration(mergeFile, false));

            var result = File.ReadAllText(Path.Combine(outputPath, sourceFile));

            mergePostAction.Execute();
            var expected = new FailedMergePostActionInfo(
                "temp\\Source_fail.cs",
                Path.Combine(outputPath, "Source_fail_postaction.cs"),
                "temp\\Source_fail_failedpostaction.cs",
                Path.Combine(outputPath, "Source_fail_failedpostaction.cs"),
                string.Format(StringRes.FailedMergePostActionLineNotFound, "namespace TestData", "temp\\Source_fail.cs", templateName),
                MergeFailureType.LineNotFound);

            Directory.Delete(outputPath, true);

            Assert.Collection <FailedMergePostActionInfo>(
                GenContext.Current.FailedMergePostActions,
                f1 =>
            {
                Assert.Equal(expected.Description, f1.Description);
                Assert.Equal(expected.FailedFileName, f1.FailedFileName);
                Assert.Equal(expected.FailedFilePath, f1.FailedFilePath);
                Assert.Equal(expected.FileName, f1.FileName);
                Assert.Equal(expected.FilePath, f1.FilePath);
                Assert.Equal(expected.MergeFailureType, f1.MergeFailureType);
            });
        }
        public void Execute_FileNotFound_NoError()
        {
            var templateName           = "Test";
            var mergeFile              = Path.GetFullPath(@".\TestData\temp\NoSource_searchreplace.cs");
            var path                   = Path.GetFullPath(@".\TestData\temp");
            var failedFileName         = @"temp\NoSource_failedpostaction.cs";
            var relativeSourceFilePath = "temp\\NoSource.cs";

            Directory.CreateDirectory(path);
            File.Copy(Path.Combine(Environment.CurrentDirectory, $"TestData\\SearchReplace\\NoSource_searchreplace.cs"), mergeFile, true);

            GenContext.Current = new FakeContextProvider()
            {
                OutputPath            = path,
                DestinationPath       = Path.GetFullPath(@".\Destination\Project"),
                DestinationParentPath = Path.GetFullPath(@".\Destination\"),
            };

            var mergePostAction = new SearchAndReplacePostAction(templateName, new MergeConfiguration(mergeFile, false));

            mergePostAction.Execute();
            var expected = new FailedMergePostActionInfo(
                relativeSourceFilePath,
                mergeFile,
                failedFileName,
                string.Format(StringRes.FailedMergePostActionFileNotFound, relativeSourceFilePath, templateName),
                MergeFailureType.FileNotFound);

            Directory.Delete(path, true);

            Assert.Collection <FailedMergePostActionInfo>(
                GenContext.Current.FailedMergePostActions,
                f1 =>
            {
                Assert.Equal(expected.Description, f1.Description);
                Assert.Equal(expected.FailedFileName, f1.FailedFileName);
                Assert.Equal(expected.FileName, f1.FileName);
                Assert.Equal(expected.FilePath, f1.FilePath);
                Assert.Equal(expected.MergeFailureType, f1.MergeFailureType);
            });
        }