public void GetCurrent_InvalidCases_ReturnsNull(string version) { var asm = AssemblyCreationHelper.CreateWithInformationalVersion(version); var actual = ApplicationVersionLocator.GetCurrent(asm); Assert.Null(actual); }
public void GetCurrent_ValidVersion_ReturnsVersion(string expectedVersion) { var asm = AssemblyCreationHelper.CreateWithInformationalVersion(expectedVersion); var actual = ApplicationVersionLocator.GetCurrent(asm); Assert.Equal(expectedVersion, actual); }
public void GetCurrent_ValidVersion_ReturnsVersion(string expectedVersion) { var name = "dynamic-assembly"; var asm = AssemblyCreationHelper.CreateWithInformationalVersion(expectedVersion, new AssemblyName(name)); var actual = ApplicationVersionLocator.GetCurrent(asm); Assert.Equal($"{name}@{expectedVersion}", actual); }
public void GetCurrent_GetEntryAssemblyNull_HttpApplicationAssembly() { var expected = ApplicationVersionLocator.GetCurrent(typeof(HttpApplication).Assembly); var actual = SystemWebVersionLocator.Resolve((string)null, Context); Assert.Equal(expected, actual); }
public void HttpApplicationAssembly_VersionParsing() { var expected = ApplicationVersionLocator.GetCurrent(typeof(HttpApplication).Assembly); var actual = SystemWebVersionLocator.Resolve(Context); Assert.Equal(expected, actual); }
public void GetCurrent_NoAsmInformationalVersion_ReturnsAsmVersion() { const string expectedVersion = "2.1.0.0"; var asmName = new AssemblyName(Guid.NewGuid().ToString()) { Version = Version.Parse(expectedVersion) }; var asm = AssemblyCreationHelper.CreateAssembly(asmName); var actual = ApplicationVersionLocator.GetCurrent(asm); Assert.Equal(expectedVersion, actual); }
public void GetCurrent_VersionWithPrefix_ReturnsVersionAsIs() { // Arrange var asm = AssemblyCreationHelper.CreateWithInformationalVersion( "[email protected]", new AssemblyName("dynamic-assembly")); // Act var version = ApplicationVersionLocator.GetCurrent(asm); // Assert version.Should().Be("[email protected]"); }
internal static string?GetCurrent(string?release) { if (release != null) { return(release); } else if (HttpContext.Current?.ApplicationInstance?.GetType() is { } type) { //Usually the type is ASP.global_asax and the BaseType is the Web Application. while (type != null && type.Namespace == "ASP") { type = type.BaseType; } if (type?.Assembly is { } assembly) { return(ApplicationVersionLocator.GetCurrent(assembly)); } } return(null); }