22
33public class PropertyInjectionTests
44{
5-
6- [ Fact ]
7- public async Task ShouldSupportInitPropertyInjection ( )
5+ [ Theory ]
6+ [ InlineData ( Lifetime . Transient ) ]
7+ [ InlineData ( Lifetime . PerBlock ) ]
8+ [ InlineData ( Lifetime . Singleton ) ]
9+ [ InlineData ( Lifetime . Scoped ) ]
10+ [ InlineData ( Lifetime . PerResolve ) ]
11+ internal async Task ShouldSupportInitPropertyInjection ( Lifetime lifetime )
812 {
913 // Given
1014
@@ -74,7 +78,7 @@ private static void SetupComposition()
7478 {
7579 DI.Setup("Composition")
7680 .Bind<IDependency>().To<Dependency>()
77- .Bind<IService>().To<Service>()
81+ .Bind<IService>().As(Lifetime.#lifetime#). To<Service>()
7882 .Root<IService>("Service")
7983 .OrdinalAttribute<CustomOrdinalAttribute>();
8084 }
@@ -89,14 +93,20 @@ public static void Main()
8993 }
9094 }
9195 }
92- """ . RunAsync ( new Options ( LanguageVersion . CSharp9 ) ) ;
96+ """ . Replace ( "#lifetime#" , lifetime . ToString ( ) ) . RunAsync ( new Options ( LanguageVersion . CSharp9 ) ) ;
9397
9498 // Then
9599 result . Success . ShouldBeTrue ( result ) ;
96100 result . StdOut . ShouldBe ( [ "OtherDep1" , "True" , "OtherDep0" , "True" ] , result ) ;
97101 }
98- [ Fact ]
99- public async Task ShouldSupportPropertyInjection ( )
102+
103+ [ Theory ]
104+ [ InlineData ( Lifetime . Transient ) ]
105+ [ InlineData ( Lifetime . PerBlock ) ]
106+ [ InlineData ( Lifetime . Singleton ) ]
107+ [ InlineData ( Lifetime . Scoped ) ]
108+ [ InlineData ( Lifetime . PerResolve ) ]
109+ internal async Task ShouldSupportPropertyInjection ( Lifetime lifetime )
100110 {
101111 // Given
102112
@@ -166,7 +176,7 @@ private static void SetupComposition()
166176 {
167177 DI.Setup("Composition")
168178 .Bind<IDependency>().To<Dependency>()
169- .Bind<IService>().To<Service>()
179+ .Bind<IService>().As(Lifetime.#lifetime#). To<Service>()
170180 .Root<IService>("Service")
171181 .OrdinalAttribute<CustomOrdinalAttribute>();
172182 }
@@ -181,7 +191,7 @@ public static void Main()
181191 }
182192 }
183193 }
184- """ . RunAsync ( ) ;
194+ """ . Replace ( "#lifetime#" , lifetime . ToString ( ) ) . RunAsync ( ) ;
185195
186196 // Then
187197 result . Success . ShouldBeTrue ( result ) ;
0 commit comments