@@ -23,13 +23,13 @@ public void Export_SingleItem_CreatesFileWithCorrectExtension(CoreUtils.ExportFo
2323 Console . SetOut ( sw ) ;
2424 // Arrange
2525 var testItem = new TestClass { Id = 1 , Name = "Test" } ;
26- var filePath = Path . Combine ( _testDirectory , "test" ) ;
26+ var filePath = "test" ;
2727
2828 // Act
29- DataExporter . Export ( filePath , testItem , format ) ;
29+ DataExporter . Export ( filePath , _testDirectory , testItem , format ) ;
3030
3131 // Assert
32- Assert . True ( File . Exists ( filePath + expectedExtension ) ) ;
32+ Assert . True ( File . Exists ( Path . Combine ( _testDirectory , filePath + expectedExtension ) ) ) ;
3333 }
3434
3535 [ Theory ]
@@ -48,7 +48,7 @@ public void ExportCollection_WithMultipleItems_CreatesFile(CoreUtils.ExportForma
4848 var filePath = Path . Combine ( _testDirectory , "collection" ) ;
4949
5050 // Act
51- DataExporter . ExportCollection ( filePath , items , format ) ;
51+ DataExporter . ExportCollection ( filePath , _testDirectory , items , format ) ;
5252
5353 // Assert
5454 Assert . True ( File . Exists ( filePath + expectedExtension ) ) ;
@@ -71,10 +71,19 @@ public void ExportMetrics_CreatesFileWithCorrectData()
7171 { "Project2" , 200 }
7272 } ;
7373 var duplications = new List < DuplicationCode > ( ) ;
74- var filePath = Path . Combine ( _testDirectory , "metrics" ) ;
74+ var filePath = "metrics" ;
75+ AnalysisResult result = new AnalysisResult
76+ {
77+ Metrics = metrics ,
78+ ProjectTotals = projectTotals ,
79+ DuplicationMap = duplications ,
80+ DependencyList = new List < DependencyRelation > ( ) ,
81+ TotalLines = 300 ,
82+ SolutionFileName = "TestSolution"
83+ } ;
7584
7685 // Act
77- DataExporter . ExportMetrics ( filePath , metrics , projectTotals , 300 , duplications , "." , CoreUtils . ExportFormat . CSV ) ;
86+ DataExporter . ExportMetrics ( filePath , _testDirectory , result , "." , CoreUtils . ExportFormat . CSV ) ;
7887
7988 // Assert
8089 Assert . True ( File . Exists ( filePath + ".csv" ) ) ;
@@ -91,10 +100,10 @@ public void ExportDuplications_CreatesFileWithCorrectData()
91100 new ( ) { CodeHash = "hash1" , FilePath = "file1.cs" , MethodName = "method1" , StartLine = 10 , NbLines = 20 } ,
92101 new ( ) { CodeHash = "hash2" , FilePath = "file2.cs" , MethodName = "method2" , StartLine = 8 , NbLines = 10 }
93102 } ;
94- var filePath = Path . Combine ( _testDirectory , "duplications" ) ;
103+ var filePath = "duplications" ;
95104
96105 // Act
97- DataExporter . ExportDuplications ( filePath , duplications , CoreUtils . ExportFormat . CSV ) ;
106+ DataExporter . ExportDuplications ( filePath , _testDirectory , duplications , CoreUtils . ExportFormat . CSV ) ;
98107
99108 // Assert
100109 Assert . True ( File . Exists ( filePath + ".csv" ) ) ;
@@ -246,14 +255,14 @@ public async Task export_dependencies_creates_files_in_correct_formats()
246255 new DependencyRelation { SourceClass = "ClassA" , SourceNamespace = "NamespaceA" , SourceAssembly = "AssemblyA" , TargetClass = "ClassB" , TargetNamespace = "NamespaceB" , TargetAssembly = "AssemblyB" , FilePath = "file1.cs" , StartLine = 10 } ,
247256 } ;
248257
249- var testFilePath = Path . Combine ( Path . GetFullPath ( "." ) , " test_export.dot") ;
258+ var testFilePath = " test_export.dot";
250259 var format = CoreUtils . ExportFormat . JSON ;
251260
252261 // Act
253- await DataExporter . ExportDependencies ( testFilePath , dependencies , format ) ;
262+ await DataExporter . ExportDependencies ( testFilePath , _testDirectory , dependencies , format ) ;
254263
255264 // Assert
256- string expectedJsonPath = CoreUtils . GetExportFileNameWithExtension ( testFilePath , format ) ;
265+ string expectedJsonPath = Path . Combine ( _testDirectory , CoreUtils . GetExportFileNameWithExtension ( testFilePath , format ) ) ;
257266 string expectedDotPath = Path . ChangeExtension ( expectedJsonPath , ".dot" ) ;
258267
259268 Assert . True ( File . Exists ( expectedJsonPath ) ) ;
@@ -285,17 +294,20 @@ public async Task export_dependencies_creates_files_in_correct_formats()
285294 [ Fact ]
286295 public void export_collection_throws_when_filepath_null ( )
287296 {
288- using var sw = new StringWriter ( ) ;
289- Console . SetOut ( sw ) ;
290- // Arrange
291- string ? filePath = null ;
292- var testData = new List < TestClass > { new TestClass { Id = 1 , Name = "Test" } } ;
293- var format = CoreUtils . ExportFormat . CSV ;
294-
295- // Act & Assert
296- var exception = Assert . Throws < ArgumentException > ( ( ) =>
297- DataExporter . ExportCollection ( filePath , testData , format ) ) ;
298- Assert . Equal ( "File path cannot be null or empty (Parameter 'filePath')" , exception . Message ) ;
297+ using ( var sw = new StringWriter ( ) )
298+ {
299+ Console . SetOut ( sw ) ;
300+ // Arrange
301+ string ? filePath = null ;
302+ var testData = new List < TestClass > { new TestClass { Id = 1 , Name = "Test" } } ;
303+ var format = CoreUtils . ExportFormat . CSV ;
304+
305+ // Act & Assert
306+ var exception = Assert . Throws < ArgumentException > ( ( ) =>
307+ DataExporter . ExportCollection ( filePath , _testDirectory , testData , format ) ) ;
308+ Assert . Contains ( "File path cannot be null or empty" , exception . Message ) ;
309+ }
310+
299311 }
300312
301313 protected virtual void Dispose ( bool disposing )
0 commit comments