public void History_Versions_ShouldAllHaveReleaseNotes() { foreach (Version version in History.Versions) { Stream stream = null; Assembly.GetAssembly(typeof(History)) .Invoking(a => stream = a.GetManifestResourceStream(History.GetResourceName(version))) .ShouldNotThrow(); stream.Should().NotBeNull($"release notes for version {version} should be located in folder VsPackage\\Resources\\ReleaseNotes and have build action 'Embedded Resource'"); using (var reader = new StreamReader(stream)) { stream = null; reader.ReadToEnd().Trim().Should().NotBeNullOrEmpty($"release notes for version {version} should have some content"); } stream?.Dispose(); } }
private string ReadReleaseNotesFile(Version version) { Stream stream = null; try { stream = Assembly.GetAssembly(typeof(History)).GetManifestResourceStream(History.GetResourceName(version)); // ReSharper disable once AssignNullToNotNullAttribute using (var reader = new StreamReader(stream)) { stream = null; return(reader.ReadToEnd().Trim()); } } catch (Exception) { return(""); } finally { stream?.Dispose(); } }