Skip to content

Commit

Permalink
IReadOnlyCollection test
Browse files Browse the repository at this point in the history
  • Loading branch information
soenneker committed Apr 18, 2024
1 parent 2ba9a55 commit 6f659df
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/AutoFaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public void Configure(Action<IAutoFakerDefaultConfigBuilder> configure)
/// <typeparam name="TType">The type of instance to generate.</typeparam>
/// <param name="configure">A handler to build the generate request configuration.</param>
/// <returns>The generated instance.</returns>
[Obsolete("")]
public static TType GenerateStatic<TType>(Action<IAutoGenerateConfigBuilder>? configure = null)
{
var faker = new AutoFaker(configure);
Expand Down
1 change: 0 additions & 1 deletion src/AutoFaker{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using Bogus;
using Soenneker.Reflection.Cache.Types;
using Soenneker.Utils.AutoBogus.Abstract;
using Soenneker.Utils.AutoBogus.Config;
using Soenneker.Utils.AutoBogus.Context;
using Soenneker.Utils.AutoBogus.Generators;
Expand Down
5 changes: 2 additions & 3 deletions test/Soenneker.Utils.AutoBogus.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Soenneker.Utils.AutoBogus.Abstract;
using Soenneker.Utils.AutoBogus.Tests.Dtos.Complex;
using Soenneker.Utils.AutoBogus.Tests.Dtos.Complex;

namespace Soenneker.Utils.AutoBogus.Tests.Console;

public class Program
{
public static void Main(string[] args)
{
IAutoFaker faker = new AutoFaker();
AutoFaker faker = new AutoFaker();

for (var i = 0; i < 10000; i++)
{
Expand Down
10 changes: 10 additions & 0 deletions test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ public void Generate_TestClassWithRecursiveConstructor_should_generate()
classObj.Name.Should().NotBeNullOrEmpty();
}

[Fact]
public void Generate_TestClassIReadOnlyCollection_should_generate()
{
var faker = new AutoFaker();

var classObj = faker.Generate<TestClassIReadOnlyCollection>();
classObj.Should().NotBeNull();
classObj.Ints.Should().NotBeNullOrEmpty();
}

[Fact]
public void Generate_Product_should_generate()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Soenneker.Utils.AutoBogus.Tests.Dtos.Complex;

/// <summary>
/// Don't modify this as it's used in benchmarking.
/// </summary>
public sealed class CustomOrder : BaseCustomOrder
{
public DateTime Timestamp;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace Soenneker.Utils.AutoBogus.Tests.Dtos.Simple
{
public class TestClassIReadOnlyCollection
{
public IReadOnlyCollection<int> Ints { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>

<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down

0 comments on commit 6f659df

Please sign in to comment.