@@ -1270,24 +1270,67 @@ static void Main()
12701270 result . StdOut . ShouldBe ( [ "136" ] , result ) ;
12711271 }
12721272
1273- private async Task ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( string argumentExpression )
1273+
1274+ [ Theory ]
1275+ [ InlineData ( 1 ) ]
1276+ [ InlineData ( 2 ) ]
1277+ [ InlineData ( 3 ) ]
1278+ [ InlineData ( 4 ) ]
1279+ [ InlineData ( 5 ) ]
1280+ [ InlineData ( 6 ) ]
1281+ [ InlineData ( 7 ) ]
1282+ [ InlineData ( 8 ) ]
1283+ [ InlineData ( 9 ) ]
1284+ [ InlineData ( 10 ) ]
1285+ [ InlineData ( 11 ) ]
1286+ [ InlineData ( 12 ) ]
1287+ [ InlineData ( 13 ) ]
1288+ [ InlineData ( 14 ) ]
1289+ [ InlineData ( 15 ) ]
1290+ [ InlineData ( 16 ) ]
1291+ [ InlineData ( 17 ) ]
1292+ [ InlineData ( 18 ) ]
1293+ [ InlineData ( 19 ) ]
1294+ [ InlineData ( 20 ) ]
1295+ [ InlineData ( 21 ) ]
1296+ [ InlineData ( 22 ) ]
1297+ [ InlineData ( 23 ) ]
1298+ [ InlineData ( 24 ) ]
1299+ [ InlineData ( 25 ) ]
1300+ [ InlineData ( 26 ) ]
1301+ [ InlineData ( 27 ) ]
1302+ [ InlineData ( 28 ) ]
1303+ [ InlineData ( 29 ) ]
1304+ [ InlineData ( 30 ) ]
1305+ public async Task ShouldSupportLightweightRootWithTaggedIntArgumentScenarios ( int value )
12741306 {
12751307 // Given
12761308
12771309 // When
12781310 var result = await $$ """
1311+ using System;
12791312 using Pure.DI;
12801313
12811314 namespace Sample;
12821315
1283- interface IService { }
1284- class Service(int id) : IService { }
1316+ interface IService
1317+ {
1318+ int Value { get; }
1319+ int DoubleValue { get; }
1320+ }
1321+
1322+ class Service([Tag("input")] int value) : IService
1323+ {
1324+ public int Value { get; } = value;
1325+
1326+ public int DoubleValue { get; } = value * 2;
1327+ }
12851328
12861329 partial class Composition
12871330 {
12881331 void Setup() => DI.Setup(nameof(Composition))
12891332 .Hint(Hint.Resolve, "Off")
1290- .RootArg<int>("id ")
1333+ .RootArg<int>("value", "input ")
12911334 .Bind<IService>().To<Service>()
12921335 .Root<IService>("Create", kind: RootKinds.Light);
12931336 }
@@ -1297,95 +1340,17 @@ class Program
12971340 static void Main()
12981341 {
12991342 var composition = new Composition();
1300- var service = composition.Create({{ argumentExpression }} );
1343+ var service = composition.Create({{ value }} );
1344+ Console.WriteLine($"{service.Value}:{service.DoubleValue}");
13011345 }
13021346 }
1303- """ . RunAsync ( new Options ( LanguageVersion . Preview , CheckCompilationErrors : false ) ) ;
1347+ """ . RunAsync ( new Options ( LanguageVersion . Preview ) ) ;
13041348
13051349 // Then
1306- result . Success . ShouldBeFalse ( result ) ;
1350+ result . Success . ShouldBeTrue ( result ) ;
1351+ result . StdOut . ShouldBe ( [ $ "{ value } :{ value * 2 } "] , result ) ;
13071352 }
13081353
1309- [ Fact ]
1310- public Task ShouldFailWhenCallingLightweightRootWithBoolArgument ( ) =>
1311- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "true" ) ;
1312-
1313- [ Fact ]
1314- public Task ShouldFailWhenCallingLightweightRootWithCharArgument ( ) =>
1315- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "'a'" ) ;
1316-
1317- [ Fact ]
1318- public Task ShouldFailWhenCallingLightweightRootWithStringArgument ( ) =>
1319- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "\" abc\" " ) ;
1320-
1321- [ Fact ]
1322- public Task ShouldFailWhenCallingLightweightRootWithNullArgument ( ) =>
1323- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "null" ) ;
1324-
1325- [ Fact ]
1326- public Task ShouldFailWhenCallingLightweightRootWithDoubleArgument ( ) =>
1327- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "1.23" ) ;
1328-
1329- [ Fact ]
1330- public Task ShouldFailWhenCallingLightweightRootWithFloatArgument ( ) =>
1331- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "1.23f" ) ;
1332-
1333- [ Fact ]
1334- public Task ShouldFailWhenCallingLightweightRootWithDecimalArgument ( ) =>
1335- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "1.23m" ) ;
1336-
1337- [ Fact ]
1338- public Task ShouldFailWhenCallingLightweightRootWithLongArgument ( ) =>
1339- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "1L" ) ;
1340-
1341- [ Fact ]
1342- public Task ShouldFailWhenCallingLightweightRootWithUIntArgument ( ) =>
1343- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "1u" ) ;
1344-
1345- [ Fact ]
1346- public Task ShouldFailWhenCallingLightweightRootWithULongArgument ( ) =>
1347- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "1ul" ) ;
1348-
1349- [ Fact ]
1350- public Task ShouldFailWhenCallingLightweightRootWithShortArgument ( ) =>
1351- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "(short)1" ) ;
1352-
1353- [ Fact ]
1354- public Task ShouldFailWhenCallingLightweightRootWithByteArgument ( ) =>
1355- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "(byte)1" ) ;
1356-
1357- [ Fact ]
1358- public Task ShouldFailWhenCallingLightweightRootWithSByteArgument ( ) =>
1359- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "(sbyte)1" ) ;
1360-
1361- [ Fact ]
1362- public Task ShouldFailWhenCallingLightweightRootWithNIntArgument ( ) =>
1363- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "(nint)1" ) ;
1364-
1365- [ Fact ]
1366- public Task ShouldFailWhenCallingLightweightRootWithNUIntArgument ( ) =>
1367- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "(nuint)1" ) ;
1368-
1369- [ Fact ]
1370- public Task ShouldFailWhenCallingLightweightRootWithObjectArgument ( ) =>
1371- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "new object()" ) ;
1372-
1373- [ Fact ]
1374- public Task ShouldFailWhenCallingLightweightRootWithDateTimeArgument ( ) =>
1375- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "System.DateTime.Now" ) ;
1376-
1377- [ Fact ]
1378- public Task ShouldFailWhenCallingLightweightRootWithGuidArgument ( ) =>
1379- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "System.Guid.NewGuid()" ) ;
1380-
1381- [ Fact ]
1382- public Task ShouldFailWhenCallingLightweightRootWithArrayArgument ( ) =>
1383- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "new[] { 1, 2, 3 }" ) ;
1384-
1385- [ Fact ]
1386- public Task ShouldFailWhenCallingLightweightRootWithLambdaArgument ( ) =>
1387- ShouldFailWhenCallingLightweightRootWithWrongIntArgument ( "() => 1" ) ;
1388-
13891354 [ Fact ]
13901355 public async Task ShouldFailWhenCallingLightweightRootWithWrongArgumentType ( )
13911356 {
0 commit comments