public void CleanUpAfterSuccess(IApprovalFailureReporter reporter) { File.Delete(received); var withCleanUp = reporter as IApprovalReporterWithCleanUp; withCleanUp?.CleanUp(approved, received); }
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); }
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); } }
private static IEnvironmentAwareReporter WrapAsEnvironmentAwareReporter(IApprovalFailureReporter mainReporter) { if (mainReporter is IEnvironmentAwareReporter reporter) { return(reporter); } return(new AlwaysWorksReporter(mainReporter)); }
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); } }
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); }
//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); }
public void CleanUpAfterSuccess(IApprovalFailureReporter reporter) { File.Delete(this.received); var withCleanUp = reporter as IApprovalReporterWithCleanUp; if (withCleanUp != null) { withCleanUp.CleanUp(this.approved, this.received); } }
public void doCleanUp(IApprovalFailureReporter reporter) { var withCleanUp = reporter as IApprovalReporterWithCleanUp; if (withCleanUp != null) { withCleanUp.CleanUp(this.approved, this.received); } }
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}>"); } }
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); }
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}>"); } }
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(); } }
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(); } } }
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(); } } }
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); }
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; }
public void ReportFailure(IApprovalFailureReporter reporter) { reporter.Report(this.approved, this.received); }
public static void Verify(IApprovalApprover approver, IApprovalFailureReporter reporter) { Approver.Verify(approver, reporter); }
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); }
public static void AssertText(string[] expected, string actual, IApprovalFailureReporter reporter = null) { AssertText(expected.JoinWith("\n"), actual); }
public static void AssertEquals(string expected, string actual, IApprovalFailureReporter reporter) { StringReporting.AssertEqual(expected, actual, reporter); }
public static void Approve(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter) { Core.Approvals.Approve(new FileApprover(writer, namer), reporter); }
public ExecutableQueryFailure(IExecutableQuery query, IApprovalFailureReporter reporter) { this.query = query; this.reporter = reporter; }
public AlwaysWorksReporter(IApprovalFailureReporter reporter) { this.reporter = reporter; }