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

            Approvals.Verify(e);
        }
예제 #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);
     }
 }
예제 #5
0
        public void TestEnsureFileExist()
        {
            var imageFile = PathUtilities.GetAdjacentFile("TestImage.png");

            if (File.Exists(imageFile))
            {
                File.Delete(imageFile);
            }
            GenericDiffReporter.EnsureFileExists(imageFile);
            Approvals.VerifyFile(imageFile);
        }
예제 #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);
        }
예제 #7
0
        public void TestGetActualProgramFileEchos()
        {
            string NoneExistingFile = @"C:\ThisDirectoryShouldNotExist\ThisFileShouldNotExist.exe";

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

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