Пример #1
0
        public void TestMethod_DumpTsv_SampleClassABC()
        {
            Dumper.IsEnabled = true;
            Dumper.Folder    = new DirectoryInfo(Path.Combine(this.TestContext.TestRunResultsDirectory, "dump"));
            Debug.WriteLine($"Dumper.Folder: {Dumper.Folder}");

            var sample =
                from i in new int[] { 1, 2, 3 }
            select new SampleClassABC {
                AB = new SampleClassAB {
                    A = i, B = true
                }, C = "Sample" + i.ToString()
            };
            var name     = this.TestContext.TestName;
            var expected = "A\tB\tC\r\n" + "1\tTrue\tSample1\r\n" + "2\tTrue\tSample2\r\n" + "3\tTrue\tSample3\r\n";

            Dumper.DumpTsv(sample, name, a => a);

            var f = Dumper.GetDumpFile(name, ".tsv");

            Debug.WriteLine(f);
            Assert.IsTrue(f.Exists, "Dump file was not created.");
            var actual = File.ReadAllText(f.FullName);

            Debug.WriteLine(actual);
            Assert.AreEqual(expected, actual, "The content of the dump file is not text that is expected.");
        } // end sub