11
11
12
12
namespace CloudinaryDotNet . IntegrationTests
13
13
{
14
- [ TestFixture ]
14
+ [ TestFixture , Parallelizable ( ParallelScope . Fixtures ) ]
15
15
public partial class IntegrationTestBase
16
16
{
17
17
protected const string CONFIG_PLACE = "appsettings.json" ;
@@ -163,12 +163,14 @@ public static string GetTaggedRandomValue()
163
163
private void SaveTestResources ( Assembly assembly )
164
164
{
165
165
string filePrefix = Path . GetDirectoryName ( assembly . Location ) ;
166
- m_testVideoPath = Path . Combine ( filePrefix , TEST_MOVIE ) ;
167
- m_testImagePath = Path . Combine ( filePrefix , TEST_IMAGE ) ;
168
- m_testUnicodeImagePath = Path . Combine ( filePrefix , TEST_UNICODE_IMAGE ) ;
169
- m_testLargeImagePath = Path . Combine ( filePrefix , TEST_LARGEIMAGE ) ;
170
- m_testPdfPath = Path . Combine ( filePrefix , TEST_PDF ) ;
171
- m_testIconPath = Path . Combine ( filePrefix , TEST_FAVICON ) ;
166
+ string testName = GetType ( ) . Name ;
167
+
168
+ m_testVideoPath = Path . Combine ( filePrefix , testName , TEST_MOVIE ) ;
169
+ m_testImagePath = Path . Combine ( filePrefix , testName , TEST_IMAGE ) ;
170
+ m_testUnicodeImagePath = Path . Combine ( filePrefix , testName , TEST_UNICODE_IMAGE ) ;
171
+ m_testLargeImagePath = Path . Combine ( filePrefix , testName , TEST_LARGEIMAGE ) ;
172
+ m_testPdfPath = Path . Combine ( filePrefix , testName , TEST_PDF ) ;
173
+ m_testIconPath = Path . Combine ( filePrefix , testName , TEST_FAVICON ) ;
172
174
173
175
SaveEmbeddedToDisk ( assembly , TEST_IMAGE , m_testImagePath ) ;
174
176
SaveEmbeddedToDisk ( assembly , TEST_IMAGE , m_testUnicodeImagePath ) ;
@@ -180,14 +182,27 @@ private void SaveTestResources(Assembly assembly)
180
182
181
183
private void SaveEmbeddedToDisk ( Assembly assembly , string sourcePath , string destPath )
182
184
{
183
- var resName = assembly . GetManifestResourceNames ( ) . FirstOrDefault ( s => s . EndsWith ( sourcePath ) ) ;
184
- if ( File . Exists ( destPath ) || string . IsNullOrEmpty ( resName ) )
185
- return ;
185
+ try
186
+ {
187
+ var resName = assembly . GetManifestResourceNames ( ) . FirstOrDefault ( s => s . EndsWith ( sourcePath ) ) ;
188
+ if ( File . Exists ( destPath ) || string . IsNullOrEmpty ( resName ) )
189
+ return ;
190
+
191
+ var directoryName = Path . GetDirectoryName ( destPath ) ;
192
+ if ( ! Directory . Exists ( directoryName ) )
193
+ {
194
+ Directory . CreateDirectory ( directoryName ) ;
195
+ }
186
196
187
- Stream stream = assembly . GetManifestResourceStream ( resName ) ;
188
- using ( FileStream fileStream = new FileStream ( destPath , FileMode . CreateNew ) )
197
+ Stream stream = assembly . GetManifestResourceStream ( resName ) ;
198
+ using ( FileStream fileStream = new FileStream ( destPath , FileMode . CreateNew ) )
199
+ {
200
+ stream . CopyTo ( fileStream ) ;
201
+ }
202
+ }
203
+ catch ( IOException e )
189
204
{
190
- stream . CopyTo ( fileStream ) ;
205
+
191
206
}
192
207
}
193
208
0 commit comments