@@ -9,86 +9,68 @@ namespace Azure.Functions.Cli.UnitTests.HelperTests
99 public class DotnetMuxerTests
1010 {
1111 [ Fact ]
12- public void DotnetMuxer_FindsMuxerPath_WhenDotnetExists ( )
12+ public void GetMuxerPath_ReturnsMuxerPath_WhenDotnetExists ( )
1313 {
14- // Arrange & Act
15- var muxer = new DotnetMuxer ( ) ;
14+ // Act
15+ var path = DotnetMuxer . GetMuxerPath ( ) ;
1616
1717 // Assert
18- Assert . NotNull ( muxer . MuxerPath ) ;
19- Assert . False ( string . IsNullOrWhiteSpace ( muxer . MuxerPath ) ) ;
18+ Assert . NotNull ( path ) ;
19+ Assert . False ( string . IsNullOrWhiteSpace ( path ) ) ;
2020 }
2121
2222 [ Fact ]
23- public void MuxerPath_ThrowsInvalidOperationException_WhenNotFound ( )
23+ public void GetMuxerPath_ContainsDotnetExecutable ( )
2424 {
25- // This test is tricky because DotnetMuxer's constructor tries to find dotnet
26- // In a normal test environment, dotnet will be found
27- // We can only test the property behavior
28- var muxer = new DotnetMuxer ( ) ;
29-
30- // If we got here, dotnet was found (which is expected in test environment)
31- Assert . NotNull ( muxer . MuxerPath ) ;
32- }
25+ // Act
26+ var path = DotnetMuxer . GetMuxerPath ( ) ;
3327
34- [ Fact ]
35- public void MuxerName_IsCorrect ( )
36- {
3728 // Assert
38- Assert . Equal ( "dotnet" , DotnetMuxer . MuxerName ) ;
39- }
40-
41- [ Fact ]
42- public void ExeSuffix_IsCorrectForPlatform ( )
43- {
44- // Act & Assert
45- if ( OperatingSystem . IsWindows ( ) )
46- {
47- Assert . Equal ( ".exe" , DotnetMuxer . ExeSuffix ) ;
48- }
49- else
50- {
51- Assert . Equal ( string . Empty , DotnetMuxer . ExeSuffix ) ;
52- }
29+ Assert . Contains ( "dotnet" , path , StringComparison . OrdinalIgnoreCase ) ;
5330 }
5431
5532 [ Fact ]
56- public void GetDataFromAppDomain_ReturnsNull_ForNonExistentKey ( )
33+ public void GetMuxerPath_PointsToExecutableFile ( )
5734 {
5835 // Act
59- var result = DotnetMuxer . GetDataFromAppDomain ( "NON_EXISTENT_KEY_12345" ) ;
36+ var path = DotnetMuxer . GetMuxerPath ( ) ;
6037
6138 // Assert
62- Assert . Null ( result ) ;
39+ // The path should exist as a file
40+ Assert . True (
41+ File . Exists ( path ) || File . Exists ( path + ".exe" ) ,
42+ $ "Expected muxer path '{ path } ' to exist") ;
6343 }
6444
6545 [ Fact ]
66- public void MuxerPath_ContainsDotnetExecutable ( )
46+ public void GetMuxerPath_PointsToFunctionalDotnetExecutable ( )
6747 {
68- // Arrange
69- var muxer = new DotnetMuxer ( ) ;
70-
7148 // Act
72- var path = muxer . MuxerPath ;
49+ var path = DotnetMuxer . GetMuxerPath ( ) ;
7350
74- // Assert
75- Assert . Contains ( "dotnet" , path , StringComparison . OrdinalIgnoreCase ) ;
76- }
51+ // Assert - invoke dotnet --version to verify it's functional
52+ var startInfo = new System . Diagnostics . ProcessStartInfo
53+ {
54+ FileName = path ,
55+ Arguments = "--version" ,
56+ RedirectStandardOutput = true ,
57+ RedirectStandardError = true ,
58+ UseShellExecute = false ,
59+ CreateNoWindow = true
60+ } ;
7761
78- [ Fact ]
79- public void MuxerPath_PointsToExecutableFile ( )
80- {
81- // Arrange
82- var muxer = new DotnetMuxer ( ) ;
62+ using var process = System . Diagnostics . Process . Start ( startInfo ) ;
63+ Assert . NotNull ( process ) ;
8364
84- // Act
85- var path = muxer . MuxerPath ;
65+ var output = process . StandardOutput . ReadToEnd ( ) ;
66+ process . WaitForExit ( ) ;
8667
8768 // Assert
88- // The path should exist as a file
89- Assert . True (
90- File . Exists ( path ) || File . Exists ( path + ".exe" ) ,
91- $ "Expected muxer path '{ path } ' to exist") ;
69+ Assert . Equal ( 0 , process . ExitCode ) ;
70+ Assert . False ( string . IsNullOrWhiteSpace ( output ) , "Expected dotnet --version to produce output" ) ;
71+
72+ // Verify output looks like a version number (e.g., "8.0.100")
73+ Assert . Matches ( @"^\d+\.\d+\.\d+" , output . Trim ( ) ) ;
9274 }
9375 }
9476}
0 commit comments