Added descriptions for all tests
All checks were successful
Nuget Pkg Build / build (push) Successful in 1m43s

This commit is contained in:
Samuele Lorefice
2026-06-15 00:39:55 +02:00
parent fda62e30bc
commit b9c4f65892
5 changed files with 39 additions and 39 deletions

View File

@@ -27,7 +27,7 @@ public class ServiceContainerConstructorSelectionTests
public NoSatisfiableCtor(int value) { } public NoSatisfiableCtor(int value) { }
} }
[Fact] [Fact(DisplayName = "Greedy constructor picks the ctor with the most parameters satisfiable by registered services")]
public void Greedy_picks_most_satisfiable_constructor() public void Greedy_picks_most_satisfiable_constructor()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -42,7 +42,7 @@ public class ServiceContainerConstructorSelectionTests
Assert.Null(instance.C); Assert.Null(instance.C);
} }
[Fact] [Fact(DisplayName = "Greedy constructor picks the ctor with all parameters satisfiable over a partial match")]
public void Greedy_picks_all_satisfied_over_partial() public void Greedy_picks_all_satisfied_over_partial()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -58,7 +58,7 @@ public class ServiceContainerConstructorSelectionTests
Assert.NotNull(instance.C); Assert.NotNull(instance.C);
} }
[Fact] [Fact(DisplayName = "Greedy constructor falls back to 1-param ctor when only 1 service is available")]
public void Greedy_falls_back_to_1_param_when_only_1_satisfiable() public void Greedy_falls_back_to_1_param_when_only_1_satisfiable()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -72,7 +72,7 @@ public class ServiceContainerConstructorSelectionTests
Assert.Null(instance.C); Assert.Null(instance.C);
} }
[Fact] [Fact(DisplayName = "Optional parameter uses its default value when the parameter type is not registered")]
public void Optional_parameter_used_when_not_registered() public void Optional_parameter_used_when_not_registered()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -84,7 +84,7 @@ public class ServiceContainerConstructorSelectionTests
Assert.Equal("default", instance.Name); Assert.Equal("default", instance.Name);
} }
[Fact] [Fact(DisplayName = "Registration-time args satisfy a constructor parameter by type matching")]
public void Registration_args_satisfy_constructor() public void Registration_args_satisfy_constructor()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -94,7 +94,7 @@ public class ServiceContainerConstructorSelectionTests
Assert.Equal(42, instance.Value); Assert.Equal(42, instance.Value);
} }
[Fact] [Fact(DisplayName = "Resolution-time args satisfy a constructor parameter when no registration-time args exist")]
public void Resolution_args_satisfy_constructor() public void Resolution_args_satisfy_constructor()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -105,7 +105,7 @@ public class ServiceContainerConstructorSelectionTests
Assert.Equal(99, instance.Value); Assert.Equal(99, instance.Value);
} }
[Fact] [Fact(DisplayName = "Resolution-time args override registration-time args of the same type in constructor selection")]
public void Resolution_args_override_registration_args() public void Resolution_args_override_registration_args()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -116,7 +116,7 @@ public class ServiceContainerConstructorSelectionTests
Assert.Equal(20, instance.Value); Assert.Equal(20, instance.Value);
} }
[Fact] [Fact(DisplayName = "Throws InvalidOperationException when no constructor has all required parameters satisfiable")]
public void No_suitable_constructor_throws() public void No_suitable_constructor_throws()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();

View File

@@ -2,7 +2,7 @@ namespace Syrette.Tests;
public class ServiceContainerDisposalTests public class ServiceContainerDisposalTests
{ {
[Fact] [Fact(DisplayName = "Dispose calls Dispose on singleton instances that implement IDisposable")]
public void Dispose_disposes_singletons_implementing_IDisposable() public void Dispose_disposes_singletons_implementing_IDisposable()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -13,7 +13,7 @@ public class ServiceContainerDisposalTests
Assert.True(instance.IsDisposed); Assert.True(instance.IsDisposed);
} }
[Fact] [Fact(DisplayName = "Dispose clears the singleton cache so subsequent resolution throws")]
public void Dispose_clears_singleton_cache() public void Dispose_clears_singleton_cache()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -26,7 +26,7 @@ public class ServiceContainerDisposalTests
container.GetService<TestDisposableService>()); container.GetService<TestDisposableService>());
} }
[Fact] [Fact(DisplayName = "Calling Dispose multiple times does not throw")]
public void Multiple_dispose_is_safe() public void Multiple_dispose_is_safe()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();

View File

@@ -2,7 +2,7 @@ namespace Syrette.Tests;
public class ServiceContainerRegistrationTests public class ServiceContainerRegistrationTests
{ {
[Fact] [Fact(DisplayName = "AddSingleton<TInterface, TImplementation> registers a service that can be resolved")]
public void AddSingleton_TInterface_TImplementation_registers_successfully() public void AddSingleton_TInterface_TImplementation_registers_successfully()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -10,7 +10,7 @@ public class ServiceContainerRegistrationTests
Assert.NotNull(container.GetService<ITestService>()); Assert.NotNull(container.GetService<ITestService>());
} }
[Fact] [Fact(DisplayName = "AddSingleton<TInterface, TImplementation> with constructor args registers and resolves")]
public void AddSingleton_TInterface_TImplementation_with_args_registers_successfully() public void AddSingleton_TInterface_TImplementation_with_args_registers_successfully()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -18,7 +18,7 @@ public class ServiceContainerRegistrationTests
Assert.NotNull(container.GetService<ITestService>()); Assert.NotNull(container.GetService<ITestService>());
} }
[Fact] [Fact(DisplayName = "AddSingleton<TClass> (self-registration) registers and resolves")]
public void AddSingleton_TClass_registers_successfully() public void AddSingleton_TClass_registers_successfully()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -26,7 +26,7 @@ public class ServiceContainerRegistrationTests
Assert.NotNull(container.GetService<TestServiceImpl>()); Assert.NotNull(container.GetService<TestServiceImpl>());
} }
[Fact] [Fact(DisplayName = "AddSingleton<TClass> with constructor args registers and resolves")]
public void AddSingleton_TClass_with_args_registers_successfully() public void AddSingleton_TClass_with_args_registers_successfully()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -34,7 +34,7 @@ public class ServiceContainerRegistrationTests
Assert.NotNull(container.GetService<TestDeepService>()); Assert.NotNull(container.GetService<TestDeepService>());
} }
[Fact] [Fact(DisplayName = "AddTransient<TInterface, TImplementation> registers a service that can be resolved")]
public void AddTransient_TInterface_TImplementation_registers_successfully() public void AddTransient_TInterface_TImplementation_registers_successfully()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -42,7 +42,7 @@ public class ServiceContainerRegistrationTests
Assert.NotNull(container.GetService<ITestService>()); Assert.NotNull(container.GetService<ITestService>());
} }
[Fact] [Fact(DisplayName = "AddTransient<TInterface, TImplementation> with constructor args registers and resolves")]
public void AddTransient_TInterface_TImplementation_with_args_registers_successfully() public void AddTransient_TInterface_TImplementation_with_args_registers_successfully()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -50,7 +50,7 @@ public class ServiceContainerRegistrationTests
Assert.NotNull(container.GetService<ITestService>()); Assert.NotNull(container.GetService<ITestService>());
} }
[Fact] [Fact(DisplayName = "AddTransient<TClass> (self-registration) registers and resolves")]
public void AddTransient_TClass_registers_successfully() public void AddTransient_TClass_registers_successfully()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -58,7 +58,7 @@ public class ServiceContainerRegistrationTests
Assert.NotNull(container.GetService<TestServiceImpl>()); Assert.NotNull(container.GetService<TestServiceImpl>());
} }
[Fact] [Fact(DisplayName = "AddTransient<TClass> with constructor args registers and resolves")]
public void AddTransient_TClass_with_args_registers_successfully() public void AddTransient_TClass_with_args_registers_successfully()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -66,7 +66,7 @@ public class ServiceContainerRegistrationTests
Assert.NotNull(container.GetService<TestDeepService>()); Assert.NotNull(container.GetService<TestDeepService>());
} }
[Fact] [Fact(DisplayName = "Fluent chaining returns the same ServiceContainer instance")]
public void Fluent_chaining_returns_same_container() public void Fluent_chaining_returns_same_container()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -76,7 +76,7 @@ public class ServiceContainerRegistrationTests
Assert.Same(container, result); Assert.Same(container, result);
} }
[Fact] [Fact(DisplayName = "Registering the same (ServiceType, ImplementationType) pair twice throws InvalidOperationException")]
public void Duplicate_registration_same_pair_throws() public void Duplicate_registration_same_pair_throws()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -85,7 +85,7 @@ public class ServiceContainerRegistrationTests
container.AddSingleton<ITestService, TestServiceImpl>()); container.AddSingleton<ITestService, TestServiceImpl>());
} }
[Fact] [Fact(DisplayName = "Registering two different implementations for the same service type is allowed and both are resolvable")]
public void Duplicate_registration_different_impl_for_same_service_allowed() public void Duplicate_registration_different_impl_for_same_service_allowed()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();

View File

@@ -2,7 +2,7 @@ namespace Syrette.Tests;
public class ServiceContainerResolutionTests public class ServiceContainerResolutionTests
{ {
[Fact] [Fact(DisplayName = "GetService<T> resolves a singleton registration")]
public void GetService_T_resolves_singleton() public void GetService_T_resolves_singleton()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -12,7 +12,7 @@ public class ServiceContainerResolutionTests
Assert.IsType<TestServiceImpl>(instance); Assert.IsType<TestServiceImpl>(instance);
} }
[Fact] [Fact(DisplayName = "GetService<T> resolves a transient registration")]
public void GetService_T_resolves_transient() public void GetService_T_resolves_transient()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -22,7 +22,7 @@ public class ServiceContainerResolutionTests
Assert.IsType<TestServiceBImpl>(instance); Assert.IsType<TestServiceBImpl>(instance);
} }
[Fact] [Fact(DisplayName = "Multiple GetService<T> calls for a singleton return the same instance")]
public void Singleton_returns_same_instance() public void Singleton_returns_same_instance()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -32,7 +32,7 @@ public class ServiceContainerResolutionTests
Assert.Same(a, b); Assert.Same(a, b);
} }
[Fact] [Fact(DisplayName = "Multiple GetService<T> calls for a transient return different instances")]
public void Transient_returns_new_instance() public void Transient_returns_new_instance()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -42,7 +42,7 @@ public class ServiceContainerResolutionTests
Assert.NotSame(a, b); Assert.NotSame(a, b);
} }
[Fact] [Fact(DisplayName = "GetService(Type) non-generic overload resolves a registered service")]
public void GetService_Type_non_generic_resolves() public void GetService_Type_non_generic_resolves()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -52,7 +52,7 @@ public class ServiceContainerResolutionTests
Assert.IsType<TestServiceImpl>(instance); Assert.IsType<TestServiceImpl>(instance);
} }
[Fact] [Fact(DisplayName = "GetService(Type, object[]) passes resolution-time args to the constructor")]
public void GetService_Type_with_args_resolves() public void GetService_Type_with_args_resolves()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -61,7 +61,7 @@ public class ServiceContainerResolutionTests
Assert.NotNull(instance); Assert.NotNull(instance);
} }
[Fact] [Fact(DisplayName = "GetService<T> throws InvalidOperationException when type is not registered")]
public void GetService_T_throws_for_unregistered() public void GetService_T_throws_for_unregistered()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -69,7 +69,7 @@ public class ServiceContainerResolutionTests
container.GetService<ITestService>()); container.GetService<ITestService>());
} }
[Fact] [Fact(DisplayName = "GetService(Type) throws InvalidOperationException when type is not registered")]
public void GetService_Type_throws_for_unregistered() public void GetService_Type_throws_for_unregistered()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -77,7 +77,7 @@ public class ServiceContainerResolutionTests
container.GetService(typeof(ITestService))); container.GetService(typeof(ITestService)));
} }
[Fact] [Fact(DisplayName = "TryGetService(Type) returns null when type is not registered")]
public void TryGetService_returns_null_for_unregistered() public void TryGetService_returns_null_for_unregistered()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -85,7 +85,7 @@ public class ServiceContainerResolutionTests
Assert.Null(result); Assert.Null(result);
} }
[Fact] [Fact(DisplayName = "TryGetService(Type) returns an instance when the type is registered")]
public void TryGetService_returns_instance_when_registered() public void TryGetService_returns_instance_when_registered()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -94,7 +94,7 @@ public class ServiceContainerResolutionTests
Assert.NotNull(result); Assert.NotNull(result);
} }
[Fact] [Fact(DisplayName = "Resolving by implementation type works when only the interface was registered")]
public void Resolve_by_implementation_type_when_not_registered_directly() public void Resolve_by_implementation_type_when_not_registered_directly()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -103,7 +103,7 @@ public class ServiceContainerResolutionTests
Assert.NotNull(instance); Assert.NotNull(instance);
} }
[Fact] [Fact(DisplayName = "Resolution-time args override registration-time args of the same type")]
public void Resolution_time_args_override_registration_time_args() public void Resolution_time_args_override_registration_time_args()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -114,7 +114,7 @@ public class ServiceContainerResolutionTests
Assert.NotEqual(Guid.Empty, deep.Id); Assert.NotEqual(Guid.Empty, deep.Id);
} }
[Fact] [Fact(DisplayName = "GetServices<T> returns instances of all registered implementations for a service type")]
public void GetServices_returns_all_registered_implementations() public void GetServices_returns_all_registered_implementations()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -127,7 +127,7 @@ public class ServiceContainerResolutionTests
Assert.Contains(typeof(TestServiceAlt), types); Assert.Contains(typeof(TestServiceAlt), types);
} }
[Fact] [Fact(DisplayName = "GetServiceTypes<T> returns the implementation types of all registered services")]
public void GetServiceTypes_returns_all_implementation_types() public void GetServiceTypes_returns_all_implementation_types()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();

View File

@@ -2,7 +2,7 @@ namespace Syrette.Tests;
public class ServiceContainerThreadingTests public class ServiceContainerThreadingTests
{ {
[Fact] [Fact(DisplayName = "Concurrent singleton resolution from multiple threads returns the same instance")]
public void Concurrent_singleton_resolution_returns_same_instance() public void Concurrent_singleton_resolution_returns_same_instance()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -21,7 +21,7 @@ public class ServiceContainerThreadingTests
} }
} }
[Fact] [Fact(DisplayName = "Concurrent transient resolution from multiple threads returns unique instances")]
public void Concurrent_transient_resolution_returns_unique_instances() public void Concurrent_transient_resolution_returns_unique_instances()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();
@@ -43,7 +43,7 @@ public class ServiceContainerThreadingTests
} }
} }
[Fact] [Fact(DisplayName = "Concurrent registration and resolution does not crash or deadlock")]
public void Concurrent_registration_and_resolution_does_not_crash() public void Concurrent_registration_and_resolution_does_not_crash()
{ {
var container = new ServiceContainer(); var container = new ServiceContainer();