public void AnalyzingSelfFindsThisMethodAndOtherStuff() { using (var tempFileManager = new TempFileManager()) { var humanReadableFile = tempFileManager.GetNew(); var computerReadableFile = tempFileManager.GetNew(); RunMain(m_ThisProjectFile, humanReadableFile, computerReadableFile, "TestCode;AssemblyApiTests", @"OurCode;AssemblyApi\."); var lines = File.ReadAllLines(humanReadableFile.FullName); var linesContainingThisMethod = lines.Where(l => l.Contains(nameof(AnalyzingSelfFindsThisMethodAndOtherStuff))).ToList(); Assert.That(linesContainingThisMethod, Has.Count.EqualTo(1)); Assert.That(lines, Has.Length.GreaterThan(15)); } }
public void RoundTripSerializationOfOwnApi() { using (var tempFileManager = new TempFileManager()) { var expectedContents = WriteHumanReadable(ThisProjectApi, tempFileManager); var expectedApi = File.ReadAllText(expectedContents.FullName); var deserializedApiNodes = RoundTrippedProjectApi; var actualContents = WriteHumanReadable(deserializedApiNodes, tempFileManager); var actualApi = File.ReadAllText(actualContents.FullName); Assert.That(actualApi, Is.EqualTo(expectedApi)); } }
private static FileInfo WriteHumanReadable(IEnumerable<IApiNode> apiNodes, TempFileManager tempFileManager) { var outputFile = tempFileManager.GetNew(); new PublicApiWriter().WriteHumanReadable(apiNodes, outputFile, CancellationToken.None).Wait(); return outputFile; }
private static IReadOnlyCollection<IApiNode> RoundTripApi(IReadOnlyCollection<IApiNode> originalApiNodes) { using (var tempFileManager = new TempFileManager()) { var outputFile = tempFileManager.GetNew(); JsonSerialization.WriteJson(originalApiNodes, outputFile); return JsonSerialization.ReadJson(outputFile); } }