99
1010using System ;
1111using Moq ;
12- using NUnit . Framework ;
1312using React . Exceptions ;
13+ using Xunit ;
1414
1515namespace React . Tests . Core
1616{
17- [ TestFixture ]
1817 public class BabelTransformerTests
1918 {
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 ( )
2826 {
2927 _environment = new Mock < IReactEnvironment > ( ) ;
3028
@@ -47,7 +45,7 @@ public void SetUp()
4745 ) ;
4846 }
4947
50- [ Test ]
48+ [ Fact ]
5149 public void ShouldTransformJsx ( )
5250 {
5351 const string input = "<div>Hello World</div>" ;
@@ -61,7 +59,7 @@ public void ShouldTransformJsx()
6159 ) ) ;
6260 }
6361
64- [ Test ]
62+ [ Fact ]
6563 public void ShouldWrapExceptionsInJsxExeption ( )
6664 {
6765 _environment . Setup ( x => x . ExecuteWithBabel < string > (
@@ -75,7 +73,7 @@ public void ShouldWrapExceptionsInJsxExeption()
7573 Assert . Throws < BabelException > ( ( ) => _babel . Transform ( input ) ) ;
7674 }
7775
78- [ Test ]
76+ [ Fact ]
7977 public void ShouldUseCacheProvider ( )
8078 {
8179 _cache . Setup ( x => x . Get < JavaScriptWithSourceMap > ( "JSX_v3_foo.jsx" , null ) ) . Returns ( new JavaScriptWithSourceMap
@@ -84,10 +82,10 @@ public void ShouldUseCacheProvider()
8482 } ) ;
8583
8684 var result = _babel . TransformFile ( "foo.jsx" ) ;
87- Assert . AreEqual ( "/* cached */" , result ) ;
85+ Assert . Equal ( "/* cached */" , result ) ;
8886 }
8987
90- [ Test ]
88+ [ Fact ]
9189 public void ShouldUseFileSystemCacheIfHashValid ( )
9290 {
9391 SetUpEmptyCache ( ) ;
@@ -96,10 +94,10 @@ public void ShouldUseFileSystemCacheIfHashValid()
9694 _fileCacheHash . Setup ( x => x . ValidateHash ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ) . Returns ( true ) ;
9795
9896 var result = _babel . TransformFile ( "foo.jsx" ) ;
99- Assert . AreEqual ( "/* filesystem cached */" , result ) ;
97+ Assert . Equal ( "/* filesystem cached */" , result ) ;
10098 }
10199
102- [ Test ]
100+ [ Fact ]
103101 public void ShouldTransformJsxIfFileCacheHashInvalid ( )
104102 {
105103 SetUpEmptyCache ( ) ;
@@ -115,10 +113,10 @@ public void ShouldTransformJsxIfFileCacheHashInvalid()
115113 ) ) . Returns ( new JavaScriptWithSourceMap { Code = "React.DOM.div('Hello World')" } ) ;
116114
117115 var result = _babel . TransformFile ( "foo.jsx" ) ;
118- StringAssert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
116+ Assert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
119117 }
120118
121- [ Test ]
119+ [ Fact ]
122120 public void ShouldTransformJsxIfNoCache ( )
123121 {
124122 SetUpEmptyCache ( ) ;
@@ -132,10 +130,10 @@ public void ShouldTransformJsxIfNoCache()
132130 ) ) . Returns ( new JavaScriptWithSourceMap { Code = "React.DOM.div('Hello World')" } ) ;
133131
134132 var result = _babel . TransformFile ( "foo.jsx" ) ;
135- StringAssert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
133+ Assert . EndsWith ( "React.DOM.div('Hello World')" , result ) ;
136134 }
137135
138- [ Test ]
136+ [ Fact ]
139137 public void ShouldSaveTransformationResult ( )
140138 {
141139 _fileSystem . Setup ( x => x . ReadAsString ( "foo.jsx" ) ) . Returns ( "<div>Hello World</div>" ) ;
@@ -152,11 +150,11 @@ public void ShouldSaveTransformationResult()
152150 ) ;
153151
154152 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 ) ;
157155 }
158156
159- [ Test ]
157+ [ Fact ]
160158 public void ShouldSkipTransformationIfCacheIsValid ( )
161159 {
162160 _fileSystem . Setup ( x => x . ReadAsString ( "foo.jsx" ) ) . Returns ( "<div>Hello World</div>" ) ;
@@ -175,8 +173,9 @@ public void ShouldSkipTransformationIfCacheIsValid()
175173 ) ;
176174
177175 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 ) ;
180179 }
181180
182181 private void SetUpEmptyCache ( )
0 commit comments