public void GetNuGetExeVersionReturnsAssemblyInformationalVersionFromProvider() { // Arrange var assembly = new Mock <ICustomAttributeProvider>(MockBehavior.Strict); assembly.Setup(s => s.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)) .Returns(new[] { new AssemblyInformationalVersionAttribute("1.2.3") }); // Act var version = SelfUpdater.GetNuGetVersion(assembly.Object); // Assert Assert.Equal("1.2.3", version.ToString()); }
public void GetNuGetExeVersionReturnsNullIfGetCustomAttributesThrows() { // Arrange var assembly = new Mock <ICustomAttributeProvider>(MockBehavior.Strict); assembly.Setup(s => s.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)) .Throws(new Exception()); // Act var version = SelfUpdater.GetNuGetVersion(assembly.Object); // Assert Assert.Null(version); }