public Configuration() { Reporter = new DiffReporter(); Comparer = new DefaultStringComparer(true); Extension = "txt"; ReaderWriter = new StringReaderWriter(); Namer = new DefaultNamer(); Sanitiser = new NullSanitiser <string>(); IsInteractive = !"true".Equals(Environment.GetEnvironmentVariable("AssentNonInteractive"), StringComparison.OrdinalIgnoreCase); }
// ReSharper disable once UnusedParameter.Local static void MyApprove(string text, object IGNORE_PAST_THIS = null, [CallerFilePath] string filepath = null, [CallerMemberName] string membername = null) { var writer = WriterFactory.CreateTextWriter(text); var filename = Path.GetFileNameWithoutExtension(filepath); var filedir = Path.GetDirectoryName(filepath); var namer = new SaneNamer { Name = filename + "." + membername, SourcePath = filedir }; var reporter = new DiffReporter(); Approver.Verify(new FileApprover(writer, namer, true), reporter); }
public static void VerifyByte(byte[] bytes, [CallerFilePath] string filepath = null, [CallerMemberName] string membername = null) { var writer = new ApprovalBinaryWriter(bytes, ".bin"); var filename = Path.GetFileNameWithoutExtension(filepath); var filedir = Path.Combine(Path.GetDirectoryName(filepath), "Result"); var namer = new SaneNamer { Name = filename + "." + membername, SourcePath = filedir }; var reporter = new DiffReporter(); Approver.Verify(new FileApprover(writer, namer, true), reporter); }
public static void VerifyXml(string text, [CallerFilePath] string filepath = null, [CallerMemberName] string membername = null) { var writer = WriterFactory.CreateTextWriter(text, ".xml"); var filename = Path.GetFileNameWithoutExtension(filepath); var filedir = Path.Combine(Path.GetDirectoryName(filepath), "Result"); var namer = new SaneNamer { Name = filename + "." + membername, SourcePath = filedir }; var reporter = new DiffReporter(); Approver.Verify(new FileApprover(writer, namer, true), reporter); }
private static void AssertLauncher(string approved, string received, DiffReporter reporter) { var args = reporter.GetLaunchArguments(approved, received); try { Approvals.Approve(args.ToString()); } catch { reporter.Launch(args); throw; } }