1
- using FluentAssertions ;
2
- using System ;
3
- using System . IO ;
4
- using System . Linq ;
5
- using Xunit ;
6
-
1
+ #pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
7
2
namespace UnityBuildRunner . Core . Tests ;
8
3
9
4
public class DefaultSettingsTest : IDisposable
@@ -33,19 +28,19 @@ public void Dispose()
33
28
[ Fact ]
34
29
public void UnityPathCanReadFromArguments ( )
35
30
{
36
- ISettings settings = DefaultSettings . Parse ( Array . Empty < string > ( ) , _unityPath , _timeout ) ;
37
- settings . UnityPath . Should ( ) . Be ( _unityPath ) ;
31
+ var settings = DefaultSettings . Parse ( [ ] , _unityPath , _timeout ) ;
32
+ Assert . Equal ( _unityPath , settings . UnityPath ) ;
38
33
}
39
34
40
35
[ Fact ]
41
36
public void UnityPathCanReadFromEnvironment ( )
42
37
{
43
38
var envName = "UnityPath" ;
44
39
Environment . SetEnvironmentVariable ( envName , _unityPath , EnvironmentVariableTarget . Process ) ;
45
- Environment . GetEnvironmentVariable ( envName ) . Should ( ) . NotBeNull ( ) ;
40
+ Assert . NotNull ( Environment . GetEnvironmentVariable ( envName ) ) ;
46
41
47
- ISettings settings = DefaultSettings . Parse ( Array . Empty < string > ( ) , "" , _timeout ) ;
48
- settings . UnityPath . Should ( ) . Be ( _unityPath ) ;
42
+ var settings = DefaultSettings . Parse ( [ ] , "" , _timeout ) ;
43
+ Assert . Equal ( _unityPath , settings . UnityPath ) ;
49
44
50
45
Environment . SetEnvironmentVariable ( envName , null , EnvironmentVariableTarget . Process ) ;
51
46
}
@@ -56,9 +51,9 @@ public void UnityPathCanReadFromEnvironment()
56
51
public void UnityPathMissingShouldThrow ( string envName , string unityPath )
57
52
{
58
53
Environment . SetEnvironmentVariable ( envName , unityPath , EnvironmentVariableTarget . Process ) ;
59
- Environment . GetEnvironmentVariable ( envName ) . Should ( ) . NotBeNull ( ) ;
54
+ Assert . NotNull ( Environment . GetEnvironmentVariable ( envName ) ) ;
60
55
61
- Assert . Throws < ArgumentNullException > ( ( ) => DefaultSettings . Parse ( Array . Empty < string > ( ) , "" , _timeout ) ) ;
56
+ Assert . Throws < ArgumentNullException > ( ( ) => DefaultSettings . Parse ( [ ] , "" , _timeout ) ) ;
62
57
63
58
Environment . SetEnvironmentVariable ( envName , null , EnvironmentVariableTarget . Process ) ;
64
59
}
@@ -68,11 +63,11 @@ public void UnityPathMissingShouldThrow(string envName, string unityPath)
68
63
[ InlineData ( new [ ] { "-logfile" , "hoge.log" , "-bathmode" , "-nographics" , "-projectpath" , "HogemogeProject" , "-executeMethod" , "MethodName" , "-quite" } , "hoge.log" ) ]
69
64
public void ParseLogfile ( string [ ] args , string logfile )
70
65
{
71
- ISettings settings = DefaultSettings . Parse ( args , _unityPath , _timeout ) ;
66
+ var settings = DefaultSettings . Parse ( args , _unityPath , _timeout ) ;
72
67
var log = DefaultSettings . ParseLogFile ( args ) ;
73
- log . Should ( ) . Be ( logfile ) ;
74
- settings . LogFilePath . Should ( ) . Be ( logfile ) ;
75
- settings . Args . Length . Should ( ) . Be ( args . Length ) ;
68
+ Assert . Equal ( logfile , log ) ;
69
+ Assert . Equal ( logfile , settings . LogFilePath ) ;
70
+ Assert . Equal ( args . Length , settings . Args . Length ) ;
76
71
}
77
72
78
73
[ Theory ]
@@ -85,8 +80,8 @@ public void ParseLogfile(string[] args, string logfile)
85
80
[ InlineData ( new [ ] { "-bathmode" , "-nographics" , "-projectpath" , " " , @"foo\bar\baz\" , "-executeMethod" , "MethodName" , "-quite" } , new [ ] { "-bathmode" , "-nographics" , "-projectpath" , @"foo\bar\baz\" , "-executeMethod" , "MethodName" , "-quite" , "-logFile" , "unitybuild.log" } ) ]
86
81
public void ArgsShouldNotContainNullOrWhiteSpace ( string [ ] actual , string [ ] expected )
87
82
{
88
- ISettings settings = DefaultSettings . Parse ( actual , _unityPath , _timeout ) ;
89
- settings . Args . SequenceEqual ( expected ) . Should ( ) . BeTrue ( ) ;
83
+ var settings = DefaultSettings . Parse ( actual , _unityPath , _timeout ) ;
84
+ Assert . True ( settings . Args . SequenceEqual ( expected ) ) ;
90
85
}
91
86
92
87
[ Theory ]
@@ -102,8 +97,8 @@ public void ArgsShouldNotContainNullOrWhiteSpace(string[] actual, string[] expec
102
97
[ InlineData ( new [ ] { "-logfile" , "\" hoge.log\" " , "-bathmode" , "-nographics" , "-projectpath" , @"""foo\bar\baz""" , "-executeMethod" , "\" MethodName\" " , "-quite" } , "-logfile \" hoge.log\" -bathmode -nographics -projectpath \" foo\\ bar\\ baz\" -executeMethod \" MethodName\" -quite" ) ] // input is already quoted
103
98
public void ArgsumentStringShouldFormated ( string [ ] actual , string expected )
104
99
{
105
- ISettings settings = DefaultSettings . Parse ( actual , _unityPath , _timeout ) ;
106
- settings . ArgumentString . Should ( ) . Be ( expected ) ;
100
+ var settings = DefaultSettings . Parse ( actual , _unityPath , _timeout ) ;
101
+ Assert . Equal ( expected , settings . ArgumentString ) ;
107
102
}
108
103
109
104
[ Theory ]
@@ -114,7 +109,7 @@ public void ArgsumentStringShouldFormated(string[] actual, string expected)
114
109
[ InlineData ( "log.log" , true ) ]
115
110
public void IsValidLogFilePath ( string ? logFilePath , bool expected )
116
111
{
117
- DefaultSettings . IsValidLogFileName ( logFilePath ) . Should ( ) . Be ( expected ) ;
112
+ Assert . Equal ( expected , DefaultSettings . IsValidLogFileName ( logFilePath ) ) ;
118
113
}
119
114
120
115
[ Theory ]
@@ -137,6 +132,6 @@ public void QuoteStringInvalidInput(string input)
137
132
[ InlineData ( "foo" , "\" foo\" " ) ]
138
133
public void QuoteStringValidValue ( string input , string expected )
139
134
{
140
- DefaultSettings . QuoteString ( input ) . Should ( ) . Be ( expected ) ;
135
+ Assert . Equal ( expected , DefaultSettings . QuoteString ( input ) ) ;
141
136
}
142
137
}
0 commit comments