Пример #1
0
 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);
 }
Пример #2
0
        // 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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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;
            }
        }