GetResourceName() public static method

public static GetResourceName ( System.Version version ) : string
version System.Version
return string
コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
            }
        }