Severity: Info
File: src/Servy.Core/Helpers/Helper.cs
Lines: 327-331
public static bool IsRunningInUnitTest()
{
// Checks if common test runners are loaded in the process
return AppDomain.CurrentDomain.GetAssemblies().Any(a => a.FullName != null && a.FullName.StartsWith(\"xunit\"));
}
The XML comment claims "common test runners" but the implementation only matches assemblies whose FullName starts with xunit. NUnit (nunit.framework), MSTest (Microsoft.VisualStudio.TestPlatform, MSTest.TestFramework), and TUnit are not detected.
Callers (DependenciesViewModel.cs:283, ServiceSearchViewModelBase.cs:130) use this guard to skip Dispatcher invocation in unit tests. Anyone running these ViewModels under NUnit/MSTest will hit Application.Current.Dispatcher calls outside a Dispatcher pump, producing flaky test failures or null-ref warnings.
Suggested fix: match any of the common test framework prefixes:
private static readonly string[] TestFrameworkPrefixes =
{
\"xunit\", \"nunit.framework\", \"Microsoft.VisualStudio.TestPlatform\",
\"Microsoft.TestPlatform\", \"MSTest.TestFramework\", \"TUnit\"
};
public static bool IsRunningInUnitTest()
{
return AppDomain.CurrentDomain.GetAssemblies().Any(a =>
a.FullName != null && TestFrameworkPrefixes.Any(prefix =>
a.FullName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)));
}
The current Servy test suite is xUnit-only, so this is dormant; rename to IsRunningUnderXunit if you want to keep the narrow scope, or expand the detection to match the doc comment.
Severity: Info
File:
src/Servy.Core/Helpers/Helper.csLines: 327-331
The XML comment claims "common test runners" but the implementation only matches assemblies whose FullName starts with
xunit. NUnit (nunit.framework), MSTest (Microsoft.VisualStudio.TestPlatform,MSTest.TestFramework), and TUnit are not detected.Callers (
DependenciesViewModel.cs:283,ServiceSearchViewModelBase.cs:130) use this guard to skip Dispatcher invocation in unit tests. Anyone running these ViewModels under NUnit/MSTest will hitApplication.Current.Dispatchercalls outside a Dispatcher pump, producing flaky test failures or null-ref warnings.Suggested fix: match any of the common test framework prefixes:
The current Servy test suite is xUnit-only, so this is dormant; rename to
IsRunningUnderXunitif you want to keep the narrow scope, or expand the detection to match the doc comment.