static MockingContext() { #if PORTABLE if (VisualStudioPortableContextResolver.IsAvailable) { registeredContextResolvers.Add(new VisualStudioPortableContextResolver()); } if (XamarinAndroidNUnitContextResolver.IsAvailable) { registeredContextResolvers.Add(new XamarinAndroidNUnitContextResolver()); } if (XamarinIosNUnitContextResolver.IsAvailable) { registeredContextResolvers.Add(new XamarinIosNUnitContextResolver()); } #else if (MSTestMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new MSTestMockingContextResolver()); } if (MSTestV2MockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new MSTestV2MockingContextResolver()); } if (XUnit1xMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new XUnit1xMockingContextResolver()); } if (XUnit2xMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new XUnit2xMockingContextResolver()); } if (NUnitMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new NUnitMockingContextResolver()); } if (MSpecContextResolver.IsAvailable) { registeredContextResolvers.Add(new MSpecContextResolver()); } if (MbUnitContextResolver.IsAvailable) { registeredContextResolvers.Add(new MbUnitContextResolver()); } #endif foreach (var resolver in registeredContextResolvers) { failThrower = resolver.GetFailMethod(); if (failThrower != null) { break; } } if (failThrower == null) { failThrower = LocalMockingContextResolver.GetFailMethod(); } }
public Action <string, Exception> GetFailMethod() { return(LocalMockingContextResolver.GetFailMethod(Type.GetType(this.assertFailedExceptionTypeName))); }
static MockingContext() { #if !PORTABLE MockingContext.Plugins = new PluginsRegistry(); AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload; try { #if !NETCORE var clrVersion = Environment.Version; if (clrVersion.Major >= 4 && clrVersion.Minor >= 0 && clrVersion.Build >= 30319 && clrVersion.Revision >= 42000) #endif { var debugWindowEnabledEnv = Environment.GetEnvironmentVariable("JUSTMOCK_DEBUG_VIEW_ENABLED"); var debugWindowServicesStringEnv = Environment.GetEnvironmentVariable("JUSTMOCK_DEBUG_VIEW_SERVICES"); var debugWindowAssemblyDirectoryEnv = Environment.GetEnvironmentVariable("JUSTMOCK_DEBUG_VIEW_PLUGIN_DIRECTORY"); if (!string.IsNullOrEmpty(debugWindowEnabledEnv) && !string.IsNullOrEmpty(debugWindowServicesStringEnv) && !string.IsNullOrEmpty(debugWindowAssemblyDirectoryEnv) && debugWindowEnabledEnv == "1" && Directory.Exists(debugWindowAssemblyDirectoryEnv)) { #if NETCORE if (Regex.IsMatch(RuntimeInformation.FrameworkDescription, NET_CORE_DESC_PATTERN)) { // append .NET Core suffix if necessary if (string.Compare(Path.GetDirectoryName(debugWindowAssemblyDirectoryEnv), NET_CORE_SUBDIR, StringComparison.InvariantCultureIgnoreCase) != 0) { debugWindowAssemblyDirectoryEnv = Path.Combine(debugWindowAssemblyDirectoryEnv, NET_CORE_SUBDIR); } } #endif var debugWindowAssemblyPath = Path.Combine(debugWindowAssemblyDirectoryEnv, DebugViewPluginAssemblyFileName); MockingContext.pluginLoadHelper = new PluginLoadHelper(debugWindowAssemblyDirectoryEnv); MockingContext.Plugins.Register <IDebugWindowPlugin>( debugWindowAssemblyPath, new ConstructorArgument("debugWindowServicesString", debugWindowServicesStringEnv)); DebugView.IsRemoteTraceEnabled = true; } } } catch (Exception e) { System.Diagnostics.Trace.WriteLine("Exception thrown during plugin registration: " + e); } #endif #if PORTABLE if (VisualStudioPortableContextResolver.IsAvailable) { registeredContextResolvers.Add(new VisualStudioPortableContextResolver()); } if (XamarinAndroidNUnitContextResolver.IsAvailable) { registeredContextResolvers.Add(new XamarinAndroidNUnitContextResolver()); } if (XamarinIosNUnitContextResolver.IsAvailable) { registeredContextResolvers.Add(new XamarinIosNUnitContextResolver()); } #else if (XUnit1xMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new XUnit1xMockingContextResolver()); } if (XUnit2xMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new XUnit2xMockingContextResolver()); } if (NUnit2xMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new NUnit2xMockingContextResolver()); } if (NUnit3xMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new NUnit3xMockingContextResolver()); } if (NUnit3_8_xMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new NUnit3_8_xMockingContextResolver()); } if (MSpecContextResolver.IsAvailable) { registeredContextResolvers.Add(new MSpecContextResolver()); } if (MbUnitContextResolver.IsAvailable) { registeredContextResolvers.Add(new MbUnitContextResolver()); } if (MSTestMockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new MSTestMockingContextResolver()); } if (MSTestV2MockingContextResolver.IsAvailable) { registeredContextResolvers.Add(new MSTestV2MockingContextResolver()); } #endif foreach (var resolver in registeredContextResolvers) { failThrower = resolver.GetFailMethod(); if (failThrower != null) { break; } } if (failThrower == null) { failThrower = LocalMockingContextResolver.GetFailMethod(); } }