Exemplo n.º 1
0
        public static void IntializeApprovalTests()
        {
            // Clear report after each Scenario
            Reporters.FinishedReport += (sender, args) =>
            {
                var reporter = args.Reporter;

                // Replace Stack Trace value of reported exceptions, because
                // content depends on runtime environment
                var steps = reporter.Report.Features
                            .SelectMany(f => f.Scenarios)
                            .SelectMany(s => new[] { s.Given, s.When, s.Then })
                            .SelectMany(s => s.Steps);

                foreach (var step in steps)
                {
                    if (step.Exception != null)
                    {
                        step.Exception.StackTrace = "<removed to make tests deterministic>";
                    }
                }

                // Verify IFileWriter
                var filepath = Path.GetTempFileName();
                reporter.WriteToFile(filepath);

                var received = File.ReadAllText(filepath);

                // HACK: Post process undeterministic attribute order
                received = received.Replace(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", "");
                received = received.Replace(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", "");

                Approvals.Verify(
                    new ApprovalStringWriter(received),
                    new ReportingApprovalNamer(reporter),
                    new NUnitReporter()
                    );
            };
        }
Exemplo n.º 2
0
        public void ConfiguringAClassLevelDefault()
        {
            var reporter = Approvals.GetReporter();

            Assert.IsInstanceOfType(reporter, typeof(_____));
        }
Exemplo n.º 3
0
        public void ConfiguringTheFileLauncherReporterAtTheMethodLevel()
        {
            var reporter = Approvals.GetReporter();

            Assert.IsInstanceOfType(reporter, typeof(FileLauncherReporter));
        }