private void TestOneFailingFile(string fileName) { var step = new RewriteStep(); var path = CreateNewTemporaryPath(); step.AssemblyConstants[AssemblyConstants.OutputPath] = path; var compilation = CreateCompilation(Path.Combine("TestFiles", "Core.qs"), "Substitution.qs", Path.Combine("TestFiles", $"{fileName}.qs")); Assert.False(step.Transformation(compilation, out var transformed)); Assert.Equal(2, step.GeneratedDiagnostics.Count()); Assert.Equal(CodeAnalysis.DiagnosticSeverity.Error, step.GeneratedDiagnostics.Last().Severity); }
private void TestOneSuccessfulFile(string fileName) { var step = new RewriteStep(); var path = CreateNewTemporaryPath(); step.AssemblyConstants[AssemblyConstants.OutputPath] = path; var compilation = CreateCompilation(Path.Combine("TestFiles", "Core.qs"), "Substitution.qs", Path.Combine("TestFiles", $"{fileName}.qs")); Assert.True(step.Transformation(compilation, out var transformed)); var generatedFileName = Path.Combine(path, "__AutoSubstitution__.g.cs"); Assert.True(File.Exists(generatedFileName)); // uncomment this line, when creating new unit tests to // create files with expected content //File.Copy(generatedFileName, $"{fileName}.cs_", true); Assert.Equal(File.ReadAllText(Path.Combine("TestFiles", $"{fileName}.cs_")).Replace("\r\n", "\n"), File.ReadAllText(generatedFileName).Replace("\r\n", "\n")); Directory.Delete(path, true); }