diff --git a/Syrette.Tests/ServiceContainerConstructorSelectionTests.cs b/Syrette.Tests/ServiceContainerConstructorSelectionTests.cs index e5dc555..4c3f5de 100644 --- a/Syrette.Tests/ServiceContainerConstructorSelectionTests.cs +++ b/Syrette.Tests/ServiceContainerConstructorSelectionTests.cs @@ -27,7 +27,7 @@ public class ServiceContainerConstructorSelectionTests 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() { var container = new ServiceContainer(); @@ -42,7 +42,7 @@ public class ServiceContainerConstructorSelectionTests 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() { var container = new ServiceContainer(); @@ -58,7 +58,7 @@ public class ServiceContainerConstructorSelectionTests 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() { var container = new ServiceContainer(); @@ -72,7 +72,7 @@ public class ServiceContainerConstructorSelectionTests 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() { var container = new ServiceContainer(); @@ -84,7 +84,7 @@ public class ServiceContainerConstructorSelectionTests Assert.Equal("default", instance.Name); } - [Fact] + [Fact(DisplayName = "Registration-time args satisfy a constructor parameter by type matching")] public void Registration_args_satisfy_constructor() { var container = new ServiceContainer(); @@ -94,7 +94,7 @@ public class ServiceContainerConstructorSelectionTests 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() { var container = new ServiceContainer(); @@ -105,7 +105,7 @@ public class ServiceContainerConstructorSelectionTests 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() { var container = new ServiceContainer(); @@ -116,7 +116,7 @@ public class ServiceContainerConstructorSelectionTests Assert.Equal(20, instance.Value); } - [Fact] + [Fact(DisplayName = "Throws InvalidOperationException when no constructor has all required parameters satisfiable")] public void No_suitable_constructor_throws() { var container = new ServiceContainer(); diff --git a/Syrette.Tests/ServiceContainerDisposalTests.cs b/Syrette.Tests/ServiceContainerDisposalTests.cs index 3d0770e..db46bac 100644 --- a/Syrette.Tests/ServiceContainerDisposalTests.cs +++ b/Syrette.Tests/ServiceContainerDisposalTests.cs @@ -2,7 +2,7 @@ namespace Syrette.Tests; public class ServiceContainerDisposalTests { - [Fact] + [Fact(DisplayName = "Dispose calls Dispose on singleton instances that implement IDisposable")] public void Dispose_disposes_singletons_implementing_IDisposable() { var container = new ServiceContainer(); @@ -13,7 +13,7 @@ public class ServiceContainerDisposalTests Assert.True(instance.IsDisposed); } - [Fact] + [Fact(DisplayName = "Dispose clears the singleton cache so subsequent resolution throws")] public void Dispose_clears_singleton_cache() { var container = new ServiceContainer(); @@ -26,7 +26,7 @@ public class ServiceContainerDisposalTests container.GetService()); } - [Fact] + [Fact(DisplayName = "Calling Dispose multiple times does not throw")] public void Multiple_dispose_is_safe() { var container = new ServiceContainer(); diff --git a/Syrette.Tests/ServiceContainerRegistrationTests.cs b/Syrette.Tests/ServiceContainerRegistrationTests.cs index e9bbd8a..5600325 100644 --- a/Syrette.Tests/ServiceContainerRegistrationTests.cs +++ b/Syrette.Tests/ServiceContainerRegistrationTests.cs @@ -2,7 +2,7 @@ namespace Syrette.Tests; public class ServiceContainerRegistrationTests { - [Fact] + [Fact(DisplayName = "AddSingleton registers a service that can be resolved")] public void AddSingleton_TInterface_TImplementation_registers_successfully() { var container = new ServiceContainer(); @@ -10,7 +10,7 @@ public class ServiceContainerRegistrationTests Assert.NotNull(container.GetService()); } - [Fact] + [Fact(DisplayName = "AddSingleton with constructor args registers and resolves")] public void AddSingleton_TInterface_TImplementation_with_args_registers_successfully() { var container = new ServiceContainer(); @@ -18,7 +18,7 @@ public class ServiceContainerRegistrationTests Assert.NotNull(container.GetService()); } - [Fact] + [Fact(DisplayName = "AddSingleton (self-registration) registers and resolves")] public void AddSingleton_TClass_registers_successfully() { var container = new ServiceContainer(); @@ -26,7 +26,7 @@ public class ServiceContainerRegistrationTests Assert.NotNull(container.GetService()); } - [Fact] + [Fact(DisplayName = "AddSingleton with constructor args registers and resolves")] public void AddSingleton_TClass_with_args_registers_successfully() { var container = new ServiceContainer(); @@ -34,7 +34,7 @@ public class ServiceContainerRegistrationTests Assert.NotNull(container.GetService()); } - [Fact] + [Fact(DisplayName = "AddTransient registers a service that can be resolved")] public void AddTransient_TInterface_TImplementation_registers_successfully() { var container = new ServiceContainer(); @@ -42,7 +42,7 @@ public class ServiceContainerRegistrationTests Assert.NotNull(container.GetService()); } - [Fact] + [Fact(DisplayName = "AddTransient with constructor args registers and resolves")] public void AddTransient_TInterface_TImplementation_with_args_registers_successfully() { var container = new ServiceContainer(); @@ -50,7 +50,7 @@ public class ServiceContainerRegistrationTests Assert.NotNull(container.GetService()); } - [Fact] + [Fact(DisplayName = "AddTransient (self-registration) registers and resolves")] public void AddTransient_TClass_registers_successfully() { var container = new ServiceContainer(); @@ -58,7 +58,7 @@ public class ServiceContainerRegistrationTests Assert.NotNull(container.GetService()); } - [Fact] + [Fact(DisplayName = "AddTransient with constructor args registers and resolves")] public void AddTransient_TClass_with_args_registers_successfully() { var container = new ServiceContainer(); @@ -66,7 +66,7 @@ public class ServiceContainerRegistrationTests Assert.NotNull(container.GetService()); } - [Fact] + [Fact(DisplayName = "Fluent chaining returns the same ServiceContainer instance")] public void Fluent_chaining_returns_same_container() { var container = new ServiceContainer(); @@ -76,7 +76,7 @@ public class ServiceContainerRegistrationTests Assert.Same(container, result); } - [Fact] + [Fact(DisplayName = "Registering the same (ServiceType, ImplementationType) pair twice throws InvalidOperationException")] public void Duplicate_registration_same_pair_throws() { var container = new ServiceContainer(); @@ -85,7 +85,7 @@ public class ServiceContainerRegistrationTests container.AddSingleton()); } - [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() { var container = new ServiceContainer(); diff --git a/Syrette.Tests/ServiceContainerResolutionTests.cs b/Syrette.Tests/ServiceContainerResolutionTests.cs index 28e9e59..4e17726 100644 --- a/Syrette.Tests/ServiceContainerResolutionTests.cs +++ b/Syrette.Tests/ServiceContainerResolutionTests.cs @@ -2,7 +2,7 @@ namespace Syrette.Tests; public class ServiceContainerResolutionTests { - [Fact] + [Fact(DisplayName = "GetService resolves a singleton registration")] public void GetService_T_resolves_singleton() { var container = new ServiceContainer(); @@ -12,7 +12,7 @@ public class ServiceContainerResolutionTests Assert.IsType(instance); } - [Fact] + [Fact(DisplayName = "GetService resolves a transient registration")] public void GetService_T_resolves_transient() { var container = new ServiceContainer(); @@ -22,7 +22,7 @@ public class ServiceContainerResolutionTests Assert.IsType(instance); } - [Fact] + [Fact(DisplayName = "Multiple GetService calls for a singleton return the same instance")] public void Singleton_returns_same_instance() { var container = new ServiceContainer(); @@ -32,7 +32,7 @@ public class ServiceContainerResolutionTests Assert.Same(a, b); } - [Fact] + [Fact(DisplayName = "Multiple GetService calls for a transient return different instances")] public void Transient_returns_new_instance() { var container = new ServiceContainer(); @@ -42,7 +42,7 @@ public class ServiceContainerResolutionTests Assert.NotSame(a, b); } - [Fact] + [Fact(DisplayName = "GetService(Type) non-generic overload resolves a registered service")] public void GetService_Type_non_generic_resolves() { var container = new ServiceContainer(); @@ -52,7 +52,7 @@ public class ServiceContainerResolutionTests Assert.IsType(instance); } - [Fact] + [Fact(DisplayName = "GetService(Type, object[]) passes resolution-time args to the constructor")] public void GetService_Type_with_args_resolves() { var container = new ServiceContainer(); @@ -61,7 +61,7 @@ public class ServiceContainerResolutionTests Assert.NotNull(instance); } - [Fact] + [Fact(DisplayName = "GetService throws InvalidOperationException when type is not registered")] public void GetService_T_throws_for_unregistered() { var container = new ServiceContainer(); @@ -69,7 +69,7 @@ public class ServiceContainerResolutionTests container.GetService()); } - [Fact] + [Fact(DisplayName = "GetService(Type) throws InvalidOperationException when type is not registered")] public void GetService_Type_throws_for_unregistered() { var container = new ServiceContainer(); @@ -77,7 +77,7 @@ public class ServiceContainerResolutionTests container.GetService(typeof(ITestService))); } - [Fact] + [Fact(DisplayName = "TryGetService(Type) returns null when type is not registered")] public void TryGetService_returns_null_for_unregistered() { var container = new ServiceContainer(); @@ -85,7 +85,7 @@ public class ServiceContainerResolutionTests Assert.Null(result); } - [Fact] + [Fact(DisplayName = "TryGetService(Type) returns an instance when the type is registered")] public void TryGetService_returns_instance_when_registered() { var container = new ServiceContainer(); @@ -94,7 +94,7 @@ public class ServiceContainerResolutionTests 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() { var container = new ServiceContainer(); @@ -103,7 +103,7 @@ public class ServiceContainerResolutionTests 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() { var container = new ServiceContainer(); @@ -114,7 +114,7 @@ public class ServiceContainerResolutionTests Assert.NotEqual(Guid.Empty, deep.Id); } - [Fact] + [Fact(DisplayName = "GetServices returns instances of all registered implementations for a service type")] public void GetServices_returns_all_registered_implementations() { var container = new ServiceContainer(); @@ -127,7 +127,7 @@ public class ServiceContainerResolutionTests Assert.Contains(typeof(TestServiceAlt), types); } - [Fact] + [Fact(DisplayName = "GetServiceTypes returns the implementation types of all registered services")] public void GetServiceTypes_returns_all_implementation_types() { var container = new ServiceContainer(); diff --git a/Syrette.Tests/ServiceContainerThreadingTests.cs b/Syrette.Tests/ServiceContainerThreadingTests.cs index 39c845c..a094f88 100644 --- a/Syrette.Tests/ServiceContainerThreadingTests.cs +++ b/Syrette.Tests/ServiceContainerThreadingTests.cs @@ -2,7 +2,7 @@ namespace Syrette.Tests; public class ServiceContainerThreadingTests { - [Fact] + [Fact(DisplayName = "Concurrent singleton resolution from multiple threads returns the same instance")] public void Concurrent_singleton_resolution_returns_same_instance() { 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() { 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() { var container = new ServiceContainer();