Skip to content

Commit cea23ec

Browse files
authored
Merge pull request #16 from maxbruecken/fix-further-regressions-while-using-iterative-approach
Fix further regressions while using iterative approach
2 parents b4dd423 + a0e5526 commit cea23ec

18 files changed

+237
-37
lines changed

FastCloner.Tests/ArrayTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
namespace FastCloner.Tests;
55

6-
[TestFixture]
7-
public class ArrayTests
6+
[TestFixture(Low)]
7+
[TestFixture(High)]
8+
public class ArrayTests(int maxRecursionDepth) : BaseTestFixture(maxRecursionDepth)
89
{
910
struct MyIntStruct
1011
{
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace FastCloner.Tests;
2+
3+
/// <summary>
4+
/// Base class for test fixtures that should run with multiple MaxRecursionDepth values.
5+
/// Inherit from this class and add [TestFixture(1)] and [TestFixture(1000)] to your test class.
6+
/// </summary>
7+
public abstract class BaseTestFixture
8+
{
9+
public const int Low = 1;
10+
public const int High = 1_000;
11+
12+
protected int MaxRecursionDepth { get; private set; }
13+
14+
protected BaseTestFixture(int maxRecursionDepth)
15+
{
16+
MaxRecursionDepth = maxRecursionDepth;
17+
}
18+
19+
[OneTimeSetUp]
20+
public void BaseOneTimeSetUp()
21+
{
22+
FastCloner.MaxRecursionDepth = MaxRecursionDepth;
23+
}
24+
25+
[OneTimeTearDown]
26+
public void BaseOneTimeTearDown()
27+
{
28+
// Reset to default
29+
FastCloner.MaxRecursionDepth = 1000;
30+
}
31+
}
32+

FastCloner.Tests/CircularTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
namespace FastCloner.Tests;
22

3-
[TestFixture]
4-
public class CircularTests
3+
[TestFixture(Low)]
4+
[TestFixture(High)]
5+
public class CircularTests(int maxRecursionDepth) : BaseTestFixture(maxRecursionDepth)
56
{
67
public class C1
78
{

FastCloner.Tests/ConcurrentTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
namespace FastCloner.Tests;
55

6-
[TestFixture]
7-
public class ConcurrentTests
6+
[TestFixture(Low)]
7+
[TestFixture(High)]
8+
public class ConcurrentTests(int maxRecursionDepth) : BaseTestFixture(maxRecursionDepth)
89
{
910
private class TestClass
1011
{
@@ -15,6 +16,9 @@ private class TestClass
1516
public void GenerateCloner_IsCalledOnlyOnce()
1617
{
1718
// Arrange
19+
// clear cache between fixtures
20+
FastClonerCache.ClearCache();
21+
1822
CountHolder generatorCallCount = new CountHolder();
1923
Type testType = typeof(TestClassForSingleCallTest);
2024

FastCloner.Tests/CopyToObjectTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
namespace FastCloner.Tests;
77

8-
[TestFixture]
9-
public class CopyToObjectTests
8+
[TestFixture(Low)]
9+
[TestFixture(High)]
10+
public class CopyToObjectTests(int maxRecursionDepth) : BaseTestFixture(maxRecursionDepth)
1011
{
1112
[Test]
1213
public void InterfaceTest()

FastCloner.Tests/CtorTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
namespace FastCloner.Tests;
44

5-
[TestFixture]
6-
public class CtorTests
5+
[TestFixture(Low)]
6+
[TestFixture(High)]
7+
public class CtorTests(int maxRecursionDepth) : BaseTestFixture(maxRecursionDepth)
78
{
89
public class T1
910
{

FastCloner.Tests/DbTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ namespace FastCloner.Tests;
1313
using NHibernate;
1414
using NHibernate.Proxy;
1515

16-
[TestFixture]
17-
public class DbTests
16+
[TestFixture(Low)]
17+
[TestFixture(High)]
18+
public class DbTests(int maxRecursionDepth) : BaseTestFixture(maxRecursionDepth)
1819
{
1920
private ISessionFactory sessionFactory;
2021
private const string DbFile = "test.db";

FastCloner.Tests/GenericTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
namespace FastCloner.Tests;
22

3-
[TestFixture]
4-
public class GenericTests
3+
[TestFixture(Low)]
4+
[TestFixture(High)]
5+
public class GenericTests(int maxRecursionDepth) : BaseTestFixture(maxRecursionDepth)
56
{
67
[Test]
78
public void Tuple_Should_Be_Cloned()

FastCloner.Tests/IgnoredTypesTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
namespace FastCloner.Tests;
55

6-
[TestFixture, NonParallelizable]
7-
public class IgnoredTypesTests
6+
[TestFixture(Low)]
7+
[TestFixture(High)]
8+
public class IgnoredTypesTests(int maxRecursionDepth) : BaseTestFixture(maxRecursionDepth)
89
{
910
public class SimpleClass
1011
{

FastCloner.Tests/InheritanceTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
namespace FastCloner.Tests;
44

5-
[TestFixture]
6-
public class InheritanceTests
5+
[TestFixture(Low)]
6+
[TestFixture(High)]
7+
public class InheritanceTests(int maxRecursionDepth) : BaseTestFixture(maxRecursionDepth)
78
{
89
public class C1 : IDisposable
910
{

0 commit comments

Comments
 (0)