diff --git a/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs b/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs index 3195f47..6367c7a 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs @@ -420,6 +420,25 @@ public void TestClassWithPrivateProperty_should_be_null() obj.GetValue().Should().BeNull(); } + [Fact] + public void TestClassWithTupleStringString_should_not_be_null() + { + var autoFaker = new AutoFaker(); + + var obj = autoFaker.Generate(); + obj.Value.Item1.Should().NotBeNull(); + obj.Value.Item2.Should().NotBeNull(); + } + + [Fact] + public void TestClassWithNullableInt_should_not_be_null() + { + var autoFaker = new AutoFaker(); + + var obj = autoFaker.Generate(); + obj.Value.Should().NotBeNull(); + } + [Fact] public void UseSeed_should_generate_same_value() { diff --git a/test/Soenneker.Utils.AutoBogus.Tests/AutoFaker{T}Tests.cs b/test/Soenneker.Utils.AutoBogus.Tests/AutoFaker{T}Tests.cs index a4a2c4f..5ec72e0 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/AutoFaker{T}Tests.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/AutoFaker{T}Tests.cs @@ -240,4 +240,27 @@ public void TestClassWithFuncCtor_should_be_null() TestClassWithFuncCtor obj = autoFaker.Generate(); obj.Should().BeNull(); } + + [Fact] + public void TestClass_with_rule_should_be_empty() + { + var autoFaker = new AutoFaker().RuleFor(c => c.Value, new List()); + var result = autoFaker.Generate(); + + result.Value.Should().BeEmpty(); + } + + [Fact] + public void TestClassWithCollectionBackedByReadOnlyCollection_with_rule_should_be_empty() + { + var config = new AutoFakerConfig + { + RecursiveDepth = 0 + }; + + var autoFaker = new AutoFaker>(config).RuleFor(c => c.PublicList, new List()); + var result = autoFaker.Generate(); + + result.PublicList.Should().BeEmpty(); + } } \ No newline at end of file diff --git a/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithCollectionBackedByReadOnlyCollection.cs b/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithCollectionBackedByReadOnlyCollection.cs new file mode 100644 index 0000000..435104e --- /dev/null +++ b/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithCollectionBackedByReadOnlyCollection.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace Soenneker.Utils.AutoBogus.Tests.Dtos.Simple; + +public class TestClassWithCollectionBackedByReadOnlyCollection +{ + public IReadOnlyCollection PublicList { get; private set; } + + protected ICollection InternalList => (ICollection)PublicList; +} \ No newline at end of file diff --git a/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithListString.cs b/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithListString.cs new file mode 100644 index 0000000..35f755b --- /dev/null +++ b/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithListString.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +namespace Soenneker.Utils.AutoBogus.Tests.Dtos.Simple; + +public class TestClassWithListString +{ + public List Value { get; set; } = default!; +} \ No newline at end of file diff --git a/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithNullableInt.cs b/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithNullableInt.cs new file mode 100644 index 0000000..cfb9e0e --- /dev/null +++ b/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithNullableInt.cs @@ -0,0 +1,8 @@ +using System; + +namespace Soenneker.Utils.AutoBogus.Tests.Dtos.Simple; + +public class TestClassWithNullableInt +{ + public Nullable Value { get; set; } +} \ No newline at end of file diff --git a/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithTupleStringString.cs b/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithTupleStringString.cs new file mode 100644 index 0000000..a0e5950 --- /dev/null +++ b/test/Soenneker.Utils.AutoBogus.Tests/Dtos/Simple/TestClassWithTupleStringString.cs @@ -0,0 +1,6 @@ +namespace Soenneker.Utils.AutoBogus.Tests.Dtos.Simple; + +public class TestClassWithTupleStringString +{ + public (string, string) Value { get; set; } +} \ No newline at end of file