11using System ;
2+ using System . Collections . Generic ;
3+ using System . IO ;
24using System . Linq ;
35using System . Reactive ;
46using System . Reactive . Linq ;
@@ -15,9 +17,9 @@ public class ImagesViewModelTests
1517 [ Fact ( DisplayName = "Gets the files correctly, ignoring unsupported files." ) ]
1618 public void GetTheFilesCorrectly ( )
1719 {
18- const string basePath = @"C:\" ;
20+ var basePath = Path . GetFullPath ( @"C:\" ) ;
1921 var allFiles = new [ ] { "image.png" , "some.gif" , "cat.mp4" , "somethingwrong.exe" }
20- . Select ( f => basePath + f ) ;
22+ . Select ( f => Path . Combine ( basePath , f ) ) ;
2123
2224 var expectedFiles = allFiles . Where ( f =>
2325 f . EndsWith ( ".png" , StringComparison . OrdinalIgnoreCase )
@@ -40,9 +42,9 @@ public void GetTheFilesCorrectly()
4042 [ Fact ( DisplayName = "Selected image is accessible by index and gives out the correct path." ) ]
4143 public void SelectedImageWorksCorrectly ( )
4244 {
43- const string basePath = @"C:\" ;
45+ var basePath = Path . GetFullPath ( @"C:\" ) ;
4446 var allFiles = new [ ] { "image.png" , "some.gif" }
45- . Select ( f => basePath + f ) ;
47+ . Select ( f => Path . Combine ( basePath , f ) ) ;
4648
4749 var fsMock = Substitute . For < IFileSystem > ( ) ;
4850
@@ -65,9 +67,9 @@ public void SelectedImageWorksCorrectly()
6567 [ Fact ( DisplayName = "Can remove and add images externally" ) ]
6668 public void CanRemoveAndAddImagesExternally ( )
6769 {
68- const string basePath = @"C:\" ;
70+ var basePath = Path . GetFullPath ( @"C:\" ) ;
6971 var allFiles = new [ ] { "image.png" , "some.gif" }
70- . Select ( f => basePath + f ) ;
72+ . Select ( f => Path . Combine ( basePath , f ) ) ;
7173
7274 var fsMock = Substitute . For < IFileSystem > ( ) ;
7375
@@ -94,9 +96,9 @@ public void CanRemoveAndAddImagesExternally()
9496 [ Fact ( DisplayName = "Search filter works" ) ]
9597 public void SearchFilterWorks ( )
9698 {
97- const string basePath = @"C:\" ;
99+ var basePath = Path . GetFullPath ( "search_test" ) ;
98100 var allFiles = new [ ] { "image.png" , "some.gif" }
99- . Select ( f => basePath + f ) ;
101+ . Select ( f => Path . Combine ( basePath , f ) ) ;
100102
101103 var fsMock = Substitute . For < IFileSystem > ( ) ;
102104
@@ -107,7 +109,7 @@ public void SearchFilterWorks()
107109 CurrentFolder = basePath
108110 } ;
109111
110- imagesVM . SearchTerm = "image" ;
112+ imagesVM . SearchTerm = "image.png " ;
111113
112114 Assert . DoesNotContain ( allFiles . ElementAt ( 1 ) , imagesVM . Images ) ;
113115
@@ -117,12 +119,12 @@ public void SearchFilterWorks()
117119 [ Fact ( DisplayName = "Can rename images" ) ]
118120 public async Task CanRenameImages ( )
119121 {
120- const string basePath = @"C:\" ;
121- const string oldFilePath = basePath + "image.png" ;
122+ var basePath = Path . GetFullPath ( "rename_test" ) ;
123+ var oldFilePath = Path . Combine ( basePath , "image.png" ) ;
122124 const string newFileName = "other_image" ;
123125 var invalidFileNames = new [ ] { @"image\ima" , "im/age" , "imag\n " , "imag\t " } ;
124126 var promptedFileName = newFileName ;
125- const string newFilePath = basePath + newFileName + ".png" ;
127+ var newFilePath = Path . Combine ( basePath , newFileName + ".png" ) ;
126128 var allFiles = new [ ] { oldFilePath } ;
127129 var allFilesResulting = new [ ] { newFilePath } ;
128130
@@ -160,15 +162,15 @@ public async Task CanRenameImages()
160162
161163 await Task . Delay ( 1 ) ;
162164
163- Assert . Equal ( allFilesResulting , imagesVM . Images ) ;
165+ Assert . Equal ( allFilesResulting , imagesVM . Images . ToArray ( ) ) ;
164166
165167 foreach ( var invalidFileName in invalidFileNames )
166168 {
167169 promptedFileName = invalidFileName ;
168170
169171 await imagesVM . RenameImage . Execute ( ) ;
170172
171- Assert . Equal ( allFilesResulting , imagesVM . Images ) ;
173+ Assert . Equal ( allFilesResulting , imagesVM . Images . ToArray ( ) ) ;
172174 }
173175
174176 Assert . True ( notifiesUserOfError ) ;
0 commit comments