9
9
10
10
using System ;
11
11
using Moq ;
12
- using NUnit . Framework ;
13
12
using React . Exceptions ;
13
+ using Xunit ;
14
14
15
15
namespace React . Tests . Core
16
16
{
17
- [ TestFixture ]
18
17
public class BabelTransformerTests
19
18
{
20
- private Mock < IReactEnvironment > _environment ;
21
- private Mock < ICache > _cache ;
22
- private Mock < IFileSystem > _fileSystem ;
23
- private Mock < IFileCacheHash > _fileCacheHash ;
24
- private Babel _babel ;
25
-
26
- [ SetUp ]
27
- public void SetUp ( )
19
+ private readonly Mock < IReactEnvironment > _environment ;
20
+ private readonly Mock < ICache > _cache ;
21
+ private readonly Mock < IFileSystem > _fileSystem ;
22
+ private readonly Mock < IFileCacheHash > _fileCacheHash ;
23
+ private readonly Babel _babel ;
24
+
25
+ public BabelTransformerTests ( )
28
26
{
29
27
_environment = new Mock < IReactEnvironment > ( ) ;
30
28
@@ -47,7 +45,7 @@ public void SetUp()
47
45
) ;
48
46
}
49
47
50
- [ Test ]
48
+ [ Fact ]
51
49
public void ShouldTransformJsx ( )
52
50
{
53
51
const string input = "<div>Hello World</div>" ;
@@ -61,7 +59,7 @@ public void ShouldTransformJsx()
61
59
) ) ;
62
60
}
63
61
64
- [ Test ]
62
+ [ Fact ]
65
63
public void ShouldWrapExceptionsInJsxExeption ( )
66
64
{
67
65
_environment . Setup ( x => x . ExecuteWithBabel < string > (
@@ -75,7 +73,7 @@ public void ShouldWrapExceptionsInJsxExeption()
75
73
Assert . Throws < BabelException > ( ( ) => _babel . Transform ( input ) ) ;
76
74
}
77
75
78
- [ Test ]
76
+ [ Fact ]
79
77
public void ShouldUseCacheProvider ( )
80
78
{
81
79
_cache . Setup ( x => x . Get < JavaScriptWithSourceMap > ( "JSX_v3_foo.jsx" , null ) ) . Returns ( new JavaScriptWithSourceMap
@@ -84,10 +82,10 @@ public void ShouldUseCacheProvider()
84
82
} ) ;
85
83
86
84
var result = _babel . TransformFile ( "foo.jsx" ) ;
87
- Assert . AreEqual ( "/* cached */" , result ) ;
85
+ Assert . Equal ( "/* cached */" , result ) ;
88
86
}
89
87
90
- [ Test ]
88
+ [ Fact ]
91
89
public void ShouldUseFileSystemCacheIfHashValid ( )
92
90
{
93
91
SetUpEmptyCache ( ) ;
@@ -96,10 +94,10 @@ public void ShouldUseFileSystemCacheIfHashValid()
96
94
_fileCacheHash . Setup ( x => x . ValidateHash ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ) . Returns ( true ) ;
97
95
98
96
var result = _babel . TransformFile ( "foo.jsx" ) ;
99
- Assert . AreEqual ( "/* filesystem cached */" , result ) ;
97
+ Assert . Equal ( "/* filesystem cached */" , result ) ;
100
98
}
101
99
102
- [ Test ]
100
+ [ Fact ]
103
101
public void ShouldTransformJsxIfFileCacheHashInvalid ( )
104
102
{
105
103
SetUpEmptyCache ( ) ;
@@ -115,10 +113,10 @@ public void ShouldTransformJsxIfFileCacheHashInvalid()
115
113
) ) . Returns ( new JavaScriptWithSourceMap { Code = "React.DOM.div('Hello World')" } ) ;
116
114
117
115
var result = _babel . TransformFile ( "foo.jsx" ) ;
118
- StringAssert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
116
+ Assert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
119
117
}
120
118
121
- [ Test ]
119
+ [ Fact ]
122
120
public void ShouldTransformJsxIfNoCache ( )
123
121
{
124
122
SetUpEmptyCache ( ) ;
@@ -132,10 +130,10 @@ public void ShouldTransformJsxIfNoCache()
132
130
) ) . Returns ( new JavaScriptWithSourceMap { Code = "React.DOM.div('Hello World')" } ) ;
133
131
134
132
var result = _babel . TransformFile ( "foo.jsx" ) ;
135
- StringAssert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
133
+ Assert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
136
134
}
137
135
138
- [ Test ]
136
+ [ Fact ]
139
137
public void ShouldSaveTransformationResult ( )
140
138
{
141
139
_fileSystem . Setup ( x => x . ReadAsString ( "foo.jsx" ) ) . Returns ( "<div>Hello World</div>" ) ;
@@ -152,11 +150,11 @@ public void ShouldSaveTransformationResult()
152
150
) ;
153
151
154
152
var resultFilename = _babel . TransformAndSaveFile ( "foo.jsx" ) ;
155
- Assert . AreEqual ( "foo.generated.js" , resultFilename ) ;
156
- StringAssert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
153
+ Assert . Equal ( "foo.generated.js" , resultFilename ) ;
154
+ Assert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
157
155
}
158
156
159
- [ Test ]
157
+ [ Fact ]
160
158
public void ShouldSkipTransformationIfCacheIsValid ( )
161
159
{
162
160
_fileSystem . Setup ( x => x . ReadAsString ( "foo.jsx" ) ) . Returns ( "<div>Hello World</div>" ) ;
@@ -175,8 +173,9 @@ public void ShouldSkipTransformationIfCacheIsValid()
175
173
) ;
176
174
177
175
var resultFilename = _babel . TransformAndSaveFile ( "foo.jsx" ) ;
178
- Assert . AreEqual ( "foo.generated.js" , resultFilename ) ;
179
- Assert . IsNull ( result , "There should be no result. Cached result should have been used." ) ;
176
+ Assert . Equal ( "foo.generated.js" , resultFilename ) ;
177
+ // There should be no result. Cached result should have been used.
178
+ Assert . Null ( result ) ;
180
179
}
181
180
182
181
private void SetUpEmptyCache ( )
0 commit comments