@@ -1062,4 +1062,88 @@ await File.WriteAllTextAsync(csprojPath, """
10621062 }
10631063
10641064 #endregion
1065+
1066+ #region EnsureAssetContentItemsAsync
1067+
1068+ [ TestMethod ]
1069+ public async Task EnsureAssetContentItems_AddsMissingAssetsGlob ( )
1070+ {
1071+ // Arrange
1072+ var csprojPath = Path . Combine ( _testTempDirectory , "Test.csproj" ) ;
1073+ File . WriteAllText ( csprojPath , @"<Project Sdk=""Microsoft.NET.Sdk"">
1074+ <PropertyGroup>
1075+ <TargetFramework>net10.0</TargetFramework>
1076+ </PropertyGroup>
1077+ </Project>
1078+ " ) ;
1079+
1080+ // Act
1081+ var result = await _dotNetService . EnsureAssetContentItemsAsync (
1082+ new FileInfo ( csprojPath ) , TestContext . CancellationToken ) ;
1083+
1084+ // Assert
1085+ Assert . IsTrue ( result , "Should modify csproj when no asset Content items exist" ) ;
1086+ var content = File . ReadAllText ( csprojPath ) ;
1087+ Assert . IsTrue ( content . Contains ( @"<Content Include=""Assets\**\*"" />" ) ,
1088+ "Should add Assets glob Content item" ) ;
1089+ Assert . IsTrue ( content . Contains ( "</Project>" ) ,
1090+ "Should preserve </Project> closing tag" ) ;
1091+ }
1092+
1093+ [ TestMethod ]
1094+ public async Task EnsureAssetContentItems_SkipsWhenAlreadyPresent ( )
1095+ {
1096+ // Arrange
1097+ var csprojPath = Path . Combine ( _testTempDirectory , "Test.csproj" ) ;
1098+ File . WriteAllText ( csprojPath , @"<Project Sdk=""Microsoft.NET.Sdk"">
1099+ <PropertyGroup>
1100+ <TargetFramework>net10.0</TargetFramework>
1101+ </PropertyGroup>
1102+ <ItemGroup>
1103+ <Content Include=""Assets\**\*"" />
1104+ </ItemGroup>
1105+ </Project>
1106+ " ) ;
1107+
1108+ // Act
1109+ var result = await _dotNetService . EnsureAssetContentItemsAsync (
1110+ new FileInfo ( csprojPath ) , TestContext . CancellationToken ) ;
1111+
1112+ // Assert
1113+ Assert . IsFalse ( result , "Should not modify csproj when asset Content items already exist" ) ;
1114+ }
1115+
1116+ [ TestMethod ]
1117+ public async Task EnsureAssetContentItems_SkipsWhenIndividualAssetPresent ( )
1118+ {
1119+ // Arrange
1120+ var csprojPath = Path . Combine ( _testTempDirectory , "Test.csproj" ) ;
1121+ File . WriteAllText ( csprojPath , @"<Project Sdk=""Microsoft.NET.Sdk"">
1122+ <ItemGroup>
1123+ <Content Include=""Assets\StoreLogo.png"" />
1124+ </ItemGroup>
1125+ </Project>
1126+ " ) ;
1127+
1128+ // Act
1129+ var result = await _dotNetService . EnsureAssetContentItemsAsync (
1130+ new FileInfo ( csprojPath ) , TestContext . CancellationToken ) ;
1131+
1132+ // Assert
1133+ Assert . IsFalse ( result , "Should not modify csproj when individual asset Content items exist" ) ;
1134+ }
1135+
1136+ [ TestMethod ]
1137+ public async Task EnsureAssetContentItems_ReturnsFalseForMissingFile ( )
1138+ {
1139+ // Act
1140+ var result = await _dotNetService . EnsureAssetContentItemsAsync (
1141+ new FileInfo ( Path . Combine ( _testTempDirectory , "NonExistent.csproj" ) ) ,
1142+ TestContext . CancellationToken ) ;
1143+
1144+ // Assert
1145+ Assert . IsFalse ( result ) ;
1146+ }
1147+
1148+ #endregion
10651149}
0 commit comments