Exemplo n.º 1
0
        public void TestMissingDots()
        {
            var e =
                ExceptionUtilities.GetException(() => GenericDiffReporter.RegisterTextFileTypes(".exe", "txt", ".error", "asp"));

            Approvals.Verify(e);
        }
Exemplo n.º 2
0
        public void TestRegisterWorks()
        {
            var r = new CodeCompareReporter();

            GenericDiffReporter.RegisterTextFileTypes(".myCrazyExtension");
            Assert.IsTrue(r.IsWorkingInThisEnvironment("file.myCrazyExtension"));
        }
 private static void AssertLauncher(string approved, string received, GenericDiffReporter reporter)
 {
     using (ApprovalResults.UniqueForMachineName())
     {
         var args = reporter.GetLaunchArguments(approved, received);
         Approvals.VerifyWithCallback(args, s => StartProcess(s));
     }
 }
 public void TestMissingDots()
 {
     using (ApprovalTests.Namers.ApprovalResults.UniqueForOs())
     {
         var e =
             ExceptionUtilities.GetException(() => GenericDiffReporter.RegisterTextFileTypes(".exe", "txt", ".error", "asp"));
         Approvals.Verify(e);
     }
 }
Exemplo n.º 5
0
        public void TestEnsureFileExist()
        {
            var imageFile = PathUtilities.GetAdjacentFile("TestImage.png");

            if (File.Exists(imageFile))
            {
                File.Delete(imageFile);
            }
            GenericDiffReporter.EnsureFileExists(imageFile);
            Approvals.VerifyFile(imageFile);
        }
Exemplo n.º 6
0
        public virtual ApprovalException Approve(string approvedPath, string receivedPath)
        {
            if (!File.Exists(approvedPath))
            {
                return(new ApprovalMissingException(receivedPath, approvedPath));
            }

            if (this.normalizeLineEndingsForTextFiles && GenericDiffReporter.IsTextFile(approvedPath))
            {
                var receivedText = File.ReadAllText(receivedPath).Replace("\r\n", "\n");
                var approvedText = File.ReadAllText(approvedPath).Replace("\r\n", "\n");

                return(!Compare(receivedText.ToCharArray(), approvedText.ToCharArray()) ?
                       new ApprovalMismatchException(receivedPath, approvedPath) :
                       null);
            }

            return(!Compare(File.ReadAllBytes(receivedPath), File.ReadAllBytes(approvedPath)) ?
                   new ApprovalMismatchException(receivedPath, approvedPath) :
                   null);
        }
Exemplo n.º 7
0
        public void TestGetActualProgramFileEchos()
        {
            string NoneExistingFile = @"C:\ThisDirectoryShouldNotExist\ThisFileShouldNotExist.exe";

            Assert.AreEqual(NoneExistingFile, GenericDiffReporter.GetActualProgramFile(NoneExistingFile));
        }
Exemplo n.º 8
0
        private static void AssertLauncher(string approved, string received, GenericDiffReporter reporter)
        {
            var args = reporter.GetLaunchArguments(approved, received);

            Approvals.VerifyWithCallback(args, s => StartProcess(s));
        }
Exemplo n.º 9
0
 public bool IsWorkingInThisEnvironment(string forFile)
 {
     return(GenericDiffReporter.IsFileOneOf(forFile, GenericDiffReporter.GetImageFileTypes()));
 }
Exemplo n.º 10
0
 public virtual bool IsWorkingInThisEnvironment(string forFile)
 {
     return(GenericDiffReporter.IsTextFile(forFile) && IsFrameworkUsed());
 }
Exemplo n.º 11
0
 public void Report(string approved, string received)
 {
     GenericDiffReporter.LaunchAsync(new LaunchArgs("excel", "/r \"{0}\"".FormatWith(approved)));
 }
Exemplo n.º 12
0
 public bool IsWorkingInThisEnvironment(string forFile)
 {
     return(File.Exists(GenericDiffReporter.GetActualProgramFile("excel")) && GenericDiffReporter.IsFileOneOf(forFile, new[] { ".xlsx", ".xls" }));
 }