Skip to content

Commit 6b88f69

Browse files
YomesIncconst-cloudinary
authored andcommitted
Speedup integration tests
1 parent 4e09e2b commit 6b88f69

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

CloudinaryDotNet.IntegrationTests/AdminApi/DeleteResourcesTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ private void AssertResourceDeleted(DelResResult result, string deletedPublicId,
7272
}
7373

7474
[Test, RetryWithDelay]
75+
[Parallelizable(ParallelScope.None)]
7576
public void TestDeleteByTransformation()
7677
{
7778
// should allow deleting resources by transformations

CloudinaryDotNet.IntegrationTests/AdminApi/ManageTransformationsTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public void TestListTransformations()
3636
}
3737

3838
[Test, RetryWithDelay]
39+
[Parallelizable(ParallelScope.None)]
3940
public async Task TestListTransformationsAsync()
4041
{
4142
// should allow listing transformations

CloudinaryDotNet.IntegrationTests/IntegrationTestBase.cs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace CloudinaryDotNet.IntegrationTests
1313
{
14-
[TestFixture]
14+
[TestFixture, Parallelizable(ParallelScope.Fixtures)]
1515
public partial class IntegrationTestBase
1616
{
1717
protected const string CONFIG_PLACE = "appsettings.json";
@@ -163,12 +163,14 @@ public static string GetTaggedRandomValue()
163163
private void SaveTestResources(Assembly assembly)
164164
{
165165
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);
172174

173175
SaveEmbeddedToDisk(assembly, TEST_IMAGE, m_testImagePath);
174176
SaveEmbeddedToDisk(assembly, TEST_IMAGE, m_testUnicodeImagePath);
@@ -180,14 +182,27 @@ private void SaveTestResources(Assembly assembly)
180182

181183
private void SaveEmbeddedToDisk(Assembly assembly, string sourcePath, string destPath)
182184
{
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+
}
186196

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)
189204
{
190-
stream.CopyTo(fileStream);
205+
191206
}
192207
}
193208

0 commit comments

Comments
 (0)