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 RhinoToNSubstituteVisitor(new Options()).Visit(input); var expected = expectedTransformation.ToFullString(); var actual = actualTransformation.ToFullString(); Assert.Equal(expected, actual); }
/// <summary> /// Convert RhinoMocks code to NSubstitute /// </summary> /// <param name="projectDir">The directory path of the project to convert.</param> public static void Main(DirectoryInfo projectDir) { if (projectDir == null) { CommandLine.InvokeMethod(new[] { "--help" }, typeof(Program).GetMethod("Main")); return; } var options = new Options { }; // todo var files = Directory.GetFiles(projectDir.FullName, "*.cs", SearchOption.AllDirectories); foreach (var file in files) { var rhinoTree = CSharpSyntaxTree.ParseText(File.ReadAllText(file)).GetRoot(); var nsubsTree = new RhinoToNSubstituteVisitor(options).Visit(rhinoTree); File.WriteAllText(file, nsubsTree.ToFullString(), Encoding.UTF8); } }