public void ReturnStoredData() { var model = new EnvironmentModel(); var httpBaseMock = new Mock<HttpContextBase>(); httpBaseMock.Setup(c => c.Application["Glimpse.AspNet.Environment"]).Returns(model); var contextMock = new Mock<ITabContext>(); contextMock.Setup(c => c.GetRequestContext<HttpContextBase>()).Returns(httpBaseMock.Object); var request = new Glimpse.AspNet.Tab.Environment(); var result = request.GetData(contextMock.Object); Assert.Same(model, result); }
public override object GetData(ITabContext context) { var httpContext = context.GetHttpContext(); var result = httpContext.Application["Glimpse.AspNet.Environment"] as EnvironmentModel; if (result == null) { result = new EnvironmentModel { WebServer = BuildWebServerDetails(httpContext), Framework = BuildFrameworkDetails(httpContext), Machine = BuildMachineDetails(), TimeZone = BuildTimeZoneDetails(), Process = BuildProcessDetails() }; FindAssemblies(result); httpContext.Application["Glimpse.AspNet.Environment"] = result; } return result; }
private void FindAssemblies(EnvironmentModel model) { var allAssemblies = FindAllAssemblies(); var sysAssemblies = new List<EnvironmentAssemblyModel>(); var appAssemblies = new List<EnvironmentAssemblyModel>(); foreach (var assembly in allAssemblies) { var assemblyName = assembly.GetName(); var name = assemblyName.Name; var version = assemblyName.Version.ToString(); var versionInfo = GetVersionNumber(assembly); var culture = string.IsNullOrEmpty(assemblyName.CultureInfo.Name) ? "neutral" : assemblyName.CultureInfo.Name; var fromGac = assembly.GlobalAssemblyCache; var fullTrust = IsFullyTrusted(assembly); var buildMode = IsAssemblyDebugBuild(assembly) == true ? "Debug" : "Release"; var result = new EnvironmentAssemblyModel { Name = name, Version = version, VersionInfo = versionInfo, Culture = culture, FromGac = fromGac, FullTrust = fullTrust, BuildMode=buildMode }; var isSystem = systemNamspaces.Any(systemNamspace => assembly.FullName.StartsWith(systemNamspace)); if (isSystem) { sysAssemblies.Add(result); } else { appAssemblies.Add(result); } } if (appAssemblies.Count > 0) { model.ApplicationAssemblies = appAssemblies; } if (sysAssemblies.Count > 0) { model.SystemAssemblies = sysAssemblies; } }