Beispiel #1
0
        private static void AssertApprover(string receivedFile, string approvedFile, bool expected)
        {
            var basePath     = PathUtilities.GetDirectoryForCaller();
            var fileApprover = new FileApprover(null, null).Approve(basePath + approvedFile, basePath + receivedFile);

            Assert.AreEqual(expected, fileApprover == null);
        }
Beispiel #2
0
        private static void AssertApprover(string receivedFile, string approvedFile, bool expected)
        {
            var basePath  = Environment.CurrentDirectory + @"\..\..\";
            var exception = FileApprover.Approve(basePath + approvedFile, basePath + receivedFile);

            Assert.AreEqual(expected, exception == null);
        }
Beispiel #3
0
        public static void Verify(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter)
        {
            var normalizeLineEndingsForTextFiles = CurrentCaller.GetFirstFrameForAttribute <IgnoreLineEndingsAttribute>();
            var shouldIgnoreLineEndings          = normalizeLineEndingsForTextFiles == null || normalizeLineEndingsForTextFiles.IgnoreLineEndings;
            var approver = new FileApprover(writer, namer, shouldIgnoreLineEndings);

            Verify(approver, reporter);
        }
Beispiel #4
0
        public void LineEndingAreNotIgnored()
        {
            var basePath     = PathUtilities.GetDirectoryForCaller();
            var approvedFile = basePath + "UnixLineEndings.txt";
            var receivedFile = basePath + "WindowsLineEndings.txt";

            File.WriteAllText(approvedFile, "Foo\nBar");
            File.WriteAllText(receivedFile, "Foo\r\nBar");
            var fileApprover = new FileApprover(null, null).Approve(approvedFile, receivedFile);

            Assert.IsInstanceOf <ApprovalMismatchException>(fileApprover);
        }
Beispiel #5
0
        public void LineEndingsAreIgnored()
        {
            var basePath     = PathUtilities.GetDirectoryForCaller();
            var approvedFile = basePath + "UnixLineEndings.txt";
            var receivedFile = basePath + "WindowsLineEndings.txt";

            File.WriteAllText(approvedFile, "Foo\nBar");
            File.WriteAllText(receivedFile, "Foo\r\nBar");
            var fileApprover = new FileApprover(null, null, true).Approve(approvedFile, receivedFile);

            Assert.IsNull(fileApprover);
        }