예제 #1
0
        internal static void RunSnapshotTest(string testCategory, string testCase)
        {
            // read input/expected syntax nodes
            var input = ReadCSharpFile(Path.Combine(testCategory, testCase, "Input.cs"));
            var expectedTransformation = ReadCSharpFile(Path.Combine(testCategory, testCase, "Expected.cs"));

            // system under test
            var actualTransformation = new NUnitToXUnitVisitor(new Options {
                ConvertAssert = true
            }).Visit(input);

            var expected = expectedTransformation.ToFullString();
            var actual   = actualTransformation.ToFullString();

            Assert.Equal(expected, actual);
        }
예제 #2
0
        public static void Main(string[] args)
        {
            // Give preferences to use the path passed as command line argument
            var        pathToLookup  = args.FirstOrDefault() ?? "{YOUR_TEST_PROJECT_DIRECTORY}";
            const bool convertAssert = false;

            var files = Directory.GetFiles(pathToLookup, "*.cs", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                var nUnitTree = CSharpSyntaxTree.ParseText(File.ReadAllText(file)).GetRoot();
                var xUnitTree = new NUnitToXUnitVisitor(new DefaultOption {
                    ConvertAssert = convertAssert
                }).Visit(nUnitTree).NormalizeWhitespace();
                File.WriteAllText(file, xUnitTree.ToFullString(), Encoding.UTF8);
            }
        }