public void CleanUpAfterSuccess(IApprovalFailureReporter reporter)
        {
            File.Delete(received);
            var withCleanUp = reporter as IApprovalReporterWithCleanUp;

            withCleanUp?.CleanUp(approved, received);
        }
Example #2
0
        public static void Verify(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter)
        {
            var normalizeLineEndingsForTextFiles = CurrentCaller.GetFirstFrameForAttribute <IgnoreLineEndingsAttribute>();
            var shouldIgnoreLineEndings          = normalizeLineEndingsForTextFiles == null || normalizeLineEndingsForTextFiles.IgnoreLineEndings;

            Approver.Verify(new FileApprover(writer, namer, shouldIgnoreLineEndings), reporter);
        }
Example #3
0
 private static IApprovalFailureReporter GetFrontLoadedReporter(IApprovalFailureReporter defaultIfNotFound,
                                                                IEnvironmentAwareReporter frontLoad)
 {
     return(frontLoad.IsWorkingInThisEnvironment("default.txt")
                ? frontLoad
                : GetReporterFromAttribute() ?? defaultIfNotFound);
 }
 public void CleanUpAfterSucess(IApprovalFailureReporter reporter)
 {
     File.Delete(received);
     if (reporter is IApprovalReporterWithCleanUp)
     {
         ((IApprovalReporterWithCleanUp)reporter).CleanUp(approved, received);
     }
 }
Example #5
0
 private static IEnvironmentAwareReporter WrapAsEnvironmentAwareReporter(IApprovalFailureReporter mainReporter)
 {
     if (mainReporter is IEnvironmentAwareReporter reporter)
     {
         return(reporter);
     }
     return(new AlwaysWorksReporter(mainReporter));
 }
Example #6
0
 public void CleanUpAfterSuccess(IApprovalFailureReporter reporter)
 {
     if (deleteOnSuccess)
     {
         File.Delete(this.received);
     }
     doCleanUp(reporter);
 }
		public void CleanUpAfterSucess(IApprovalFailureReporter reporter)
		{
			File.Delete(received);
			if (reporter is IApprovalReporterWithCleanUp)
			{
				((IApprovalReporterWithCleanUp)reporter).CleanUp(approved, received);
			}
		}
Example #8
0
 public static void AssertText(string expected, string actual, IApprovalFailureReporter reporter = null)
 {
     if (reporter == null)
     {
         reporter = GetReporter(DiffReporter.INSTANCE);
     }
     reporter = new MultiReporter(reporter, InlineTextReporter.INSTANCE);
     StringReporting.AssertEqual(expected, actual, reporter);
 }
Example #9
0
        //begin-snippet: complete_verify_call
        public static void Verify(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter)
        //end-snippet
        {
            var normalizeLineEndingsForTextFiles = CurrentCaller.GetFirstFrameForAttribute <IgnoreLineEndingsAttribute>();
            var shouldIgnoreLineEndings          = normalizeLineEndingsForTextFiles == null || normalizeLineEndingsForTextFiles.IgnoreLineEndings;
            var approver = GetDefaultApprover(writer, namer, shouldIgnoreLineEndings);

            Verify(approver, reporter);
        }
Example #10
0
 public void CleanUpAfterSuccess(IApprovalFailureReporter reporter)
 {
     File.Delete(this.received);
     var withCleanUp = reporter as IApprovalReporterWithCleanUp;
     if (withCleanUp != null)
     {
         withCleanUp.CleanUp(this.approved, this.received);
     }
 }
Example #11
0
        public void doCleanUp(IApprovalFailureReporter reporter)
        {
            var withCleanUp = reporter as IApprovalReporterWithCleanUp;

            if (withCleanUp != null)
            {
                withCleanUp.CleanUp(this.approved, this.received);
            }
        }
Example #12
0
        public void CleanUpAfterSuccess(IApprovalFailureReporter reporter)
        {
            File.Delete(this.received);
            var withCleanUp = reporter as IApprovalReporterWithCleanUp;

            if (withCleanUp != null)
            {
                withCleanUp.CleanUp(this.approved, this.received);
            }
        }
        public static void AssertEqual(string expected, string actual, IApprovalFailureReporter reporter)
        {
            if (expected != actual)
            {
                var expectedFile = Path.GetTempPath() + "Expected.Approvals.Temp.txt";
                var actualFile = Path.GetTempPath() + "Actual.Approvals.Temp.txt";

                File.WriteAllText(expectedFile, expected);
                File.WriteAllText(actualFile, actual);

                reporter.Report(expectedFile, actualFile);
                throw new Exception($"<{expected}> != <{actual}>");
            }
        }
Example #14
0
        public static void Verify(IApprovalApprover approver, IApprovalFailureReporter reporter)
        {
            if (approver.Approve())
            {
                approver.CleanUpAfterSuccess(reporter);
            }
            else
            {
                approver.ReportFailure(reporter);

                if (reporter is IReporterWithApprovalPower power && power.ApprovedWhenReported())
                {
                    approver.CleanUpAfterSuccess(power);
                }
Example #15
0
        public static void AssertEqual(string expected, string actual, IApprovalFailureReporter reporter)
        {
            if (expected != actual)
            {
                var expectedFile = Path.GetTempPath() + "Expected.Approvals.Temp.txt";
                var actualFile   = Path.GetTempPath() + "Actual.Approvals.Temp.txt";

                File.WriteAllText(expectedFile, expected);
                File.WriteAllText(actualFile, actual);

                reporter.Report(expectedFile, actualFile);
                throw new Exception($"<{expected}> != <{actual}>");
            }
        }
Example #16
0
        public static void Verify(IApprovalApprover approver, IApprovalFailureReporter reporter)
        {
            if (approver.Approve())
                approver.CleanUpAfterSucess(reporter);
            else
            {
                approver.ReportFailure(reporter);

                if (reporter is IReporterWithApprovalPower && ((IReporterWithApprovalPower)reporter).ApprovedWhenReported())
                    approver.CleanUpAfterSucess(reporter);
                else
                    approver.Fail();
            }
        }
Example #17
0
        public static void Approve(IApprovalApprover approver, IApprovalFailureReporter reporter)
        {
            if (approver.Approve())
            {
                approver.CleanUpAfterSucess(reporter);
            }
            else
            {
                approver.ReportFailure(reporter);

                if (reporter is IReporterWithApprovalPower && ((IReporterWithApprovalPower)reporter).ApprovedWhenReported())
                {
                    approver.CleanUpAfterSucess(reporter);
                }
                else
                {
                    approver.Fail();
                }
            }
        }
Example #18
0
        public static void Verify(IApprovalApprover approver, IApprovalFailureReporter reporter)
        {
            if (approver.Approve())
            {
                approver.CleanUpAfterSuccess(reporter);
            }
            else
            {
                approver.ReportFailure(reporter);

                var power = reporter as IReporterWithApprovalPower;
                if (power != null && power.ApprovedWhenReported())
                {
                    approver.CleanUpAfterSuccess(power);
                }
                else
                {
                    approver.Fail();
                }
            }
        }
Example #19
0
        private static IApprovalFailureReporter DetermineReporter()
        {
            IApprovalFailureReporter approvalFailureReporter = Approvals.GetReporter();

            string typeName = Environment.GetEnvironmentVariable("ApiApproval.Reporter");

            if (!string.IsNullOrWhiteSpace(typeName))
            {
                if (!typeName.Contains("."))
                {
                    typeName = "ApprovalTests.Reporters." + typeName;
                }

                if (!typeName.EndsWith("Reporter"))
                {
                    typeName += "Reporter";
                }

                Type type = typeof(IApprovalFailureReporter).Assembly.GetType(typeName, throwOnError: true, ignoreCase: true);
                approvalFailureReporter = (IApprovalFailureReporter)Activator.CreateInstance(type);
            }

            return(approvalFailureReporter);
        }
Example #20
0
 public static IApprovalFailureReporter GetReporter(IApprovalFailureReporter defaultIfNotFound)
 {
     return(GetReporterFromAttribute() ?? defaultIfNotFound);
 }
 public void ReportFailure(IApprovalFailureReporter reporter)
 {
     reporter.Report(_approved, _received);
 }
 public void ReportFailure(IApprovalFailureReporter reporter)
 {
     reporter.Report(approved, received);
 }
 public ExecutableQueryFailure(IExecutableQuery query, IApprovalFailureReporter reporter)
 {
     this.query = query;
     this.reporter = reporter;
 }
Example #24
0
 public void ReportFailure(IApprovalFailureReporter reporter)
 {
     reporter.Report(this.approved, this.received);
 }
Example #25
0
 public static void Verify(IApprovalApprover approver, IApprovalFailureReporter reporter)
 {
     Approver.Verify(approver, reporter);
 }
Example #26
0
 public static IApprovalFailureReporter GetReporter(IApprovalFailureReporter defaultIfNotFound)
 {
     return(GetFrontLoadedReporter(defaultIfNotFound, GetFrontLoadedReporterFromAttribute()));
 }
 public void doCleanUp(IApprovalFailureReporter reporter)
 {
     var withCleanUp = reporter as IApprovalReporterWithCleanUp;
     if (withCleanUp != null)
     {
         withCleanUp.CleanUp(this.approved, this.received);
     }
 }
 public void CleanUpAfterSuccess(IApprovalFailureReporter reporter)
 {
     if (deleteOnSuccess)
     {
         File.Delete(this.received);
     }
     doCleanUp(reporter);
 }
Example #29
0
 public static void AssertText(string[] expected, string actual, IApprovalFailureReporter reporter = null)
 {
     AssertText(expected.JoinWith("\n"), actual);
 }
Example #30
0
 public static void AssertEquals(string expected, string actual, IApprovalFailureReporter reporter)
 {
     StringReporting.AssertEqual(expected, actual, reporter);
 }
Example #31
0
 public static void Approve(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter)
 {
     Core.Approvals.Approve(new FileApprover(writer, namer), reporter);
 }
Example #32
0
 public ExecutableQueryFailure(IExecutableQuery query, IApprovalFailureReporter reporter)
 {
     this.query    = query;
     this.reporter = reporter;
 }
 public AlwaysWorksReporter(IApprovalFailureReporter reporter)
 {
     this.reporter = reporter;
 }