Skip to content

Commit

Permalink
Speedup integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YomesInc authored and const-cloudinary committed Jun 23, 2021
1 parent 4e09e2b commit 6b88f69
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private void AssertResourceDeleted(DelResResult result, string deletedPublicId,
}

[Test, RetryWithDelay]
[Parallelizable(ParallelScope.None)]
public void TestDeleteByTransformation()
{
// should allow deleting resources by transformations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void TestListTransformations()
}

[Test, RetryWithDelay]
[Parallelizable(ParallelScope.None)]
public async Task TestListTransformationsAsync()
{
// should allow listing transformations
Expand Down
41 changes: 28 additions & 13 deletions CloudinaryDotNet.IntegrationTests/IntegrationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace CloudinaryDotNet.IntegrationTests
{
[TestFixture]
[TestFixture, Parallelizable(ParallelScope.Fixtures)]
public partial class IntegrationTestBase
{
protected const string CONFIG_PLACE = "appsettings.json";
Expand Down Expand Up @@ -163,12 +163,14 @@ public static string GetTaggedRandomValue()
private void SaveTestResources(Assembly assembly)
{
string filePrefix = Path.GetDirectoryName(assembly.Location);
m_testVideoPath = Path.Combine(filePrefix, TEST_MOVIE);
m_testImagePath = Path.Combine(filePrefix, TEST_IMAGE);
m_testUnicodeImagePath = Path.Combine(filePrefix, TEST_UNICODE_IMAGE);
m_testLargeImagePath = Path.Combine(filePrefix, TEST_LARGEIMAGE);
m_testPdfPath = Path.Combine(filePrefix, TEST_PDF);
m_testIconPath = Path.Combine(filePrefix, TEST_FAVICON);
string testName = GetType().Name;

m_testVideoPath = Path.Combine(filePrefix, testName, TEST_MOVIE);
m_testImagePath = Path.Combine(filePrefix, testName, TEST_IMAGE);
m_testUnicodeImagePath = Path.Combine(filePrefix, testName, TEST_UNICODE_IMAGE);
m_testLargeImagePath = Path.Combine(filePrefix, testName, TEST_LARGEIMAGE);
m_testPdfPath = Path.Combine(filePrefix, testName, TEST_PDF);
m_testIconPath = Path.Combine(filePrefix, testName, TEST_FAVICON);

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

private void SaveEmbeddedToDisk(Assembly assembly, string sourcePath, string destPath)
{
var resName = assembly.GetManifestResourceNames().FirstOrDefault(s => s.EndsWith(sourcePath));
if (File.Exists(destPath) || string.IsNullOrEmpty(resName))
return;
try
{
var resName = assembly.GetManifestResourceNames().FirstOrDefault(s => s.EndsWith(sourcePath));
if (File.Exists(destPath) || string.IsNullOrEmpty(resName))
return;

var directoryName = Path.GetDirectoryName(destPath);
if (!Directory.Exists(directoryName))
{
Directory.CreateDirectory(directoryName);
}

Stream stream = assembly.GetManifestResourceStream(resName);
using (FileStream fileStream = new FileStream(destPath, FileMode.CreateNew))
Stream stream = assembly.GetManifestResourceStream(resName);
using (FileStream fileStream = new FileStream(destPath, FileMode.CreateNew))
{
stream.CopyTo(fileStream);
}
}
catch (IOException e)
{
stream.CopyTo(fileStream);

}
}

Expand Down

0 comments on commit 6b88f69

Please sign in to comment.