diff --git a/README.md b/README.md index e12fc58..58078de 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ public class OrderOverride : AutoFakerOverride Then just add `AutoFakerOverride` to the `AutoFaker.Config` instance: ```csharp -autoFaker.Config.Overrides = new AutoFakerOverrides(); +autoFaker.Config.Overrides = new List(); autoFaker.Config.Overrides.Add(new OrderOverride()); ``` diff --git a/src/AutoFaker.cs b/src/AutoFaker.cs index fdcb6d0..d25427d 100644 --- a/src/AutoFaker.cs +++ b/src/AutoFaker.cs @@ -63,7 +63,7 @@ public List Generate(int count) public object Generate(Type type) { - CachedType autoFakerType = CacheService.Cache.GetCachedType(typeof(AutoFaker)); + CachedType autoFakerType = CachedTypeService.AutoFaker.Value; // TODO: Optimize MethodInfo method = autoFakerType.Type.GetMethod("Generate", BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null).MakeGenericMethod(type); diff --git a/src/Services/CachedTypeService.cs b/src/Services/CachedTypeService.cs index 06bfd5b..b0699a3 100644 --- a/src/Services/CachedTypeService.cs +++ b/src/Services/CachedTypeService.cs @@ -19,4 +19,5 @@ internal static class CachedTypeService internal static readonly Lazy IDictionary = new(() => CacheService.Cache.GetCachedType(typeof(IDictionary<,>))); internal static readonly Lazy IEnumerable = new(() => CacheService.Cache.GetCachedType(typeof(IEnumerable<>))); + internal static readonly Lazy AutoFaker = new(() => CacheService.Cache.GetCachedType(typeof(AutoFaker))); } \ No newline at end of file diff --git a/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs b/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs index 8c02c90..b91238b 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs @@ -38,9 +38,6 @@ public void Generate_struct_should_generate() var structObj = faker.Generate(); structObj.Should().NotBeNull(); - - // product.Reviews.Count.Should().BeGreaterThan(0); - // product. } [Fact] @@ -51,8 +48,6 @@ public void Generate_Product_should_generate() var product = faker.Generate(); product.Should().NotBeNull(); product.GetRevisions.Should().NotBeNullOrEmpty(); - // product.Reviews.Count.Should().BeGreaterThan(0); - // product. } [Fact] @@ -75,7 +70,7 @@ public void Generate_many_int_should_generate() { var faker = new AutoFaker(); - List intList = new List(); + var intList = new List(); for (var i = 0; i < 1000; i++) { diff --git a/test/Soenneker.Utils.AutoBogus.Tests/AutoGenerateContextFixture.cs b/test/Soenneker.Utils.AutoBogus.Tests/AutoGenerateContextFixture.cs index 24aa15c..12c227a 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/AutoGenerateContextFixture.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/AutoGenerateContextFixture.cs @@ -21,8 +21,6 @@ public AutoGenerateContextFixture() _faker = new Faker(); _ruleSets = new List(); _fakerConfig = new AutoFakerConfig(); - - //ConfigService.SetCustomConfig(_fakerConfig); } public class GenerateMany_Internal diff --git a/test/Soenneker.Utils.AutoBogus.Tests/GenericTypeUtilTests.cs b/test/Soenneker.Utils.AutoBogus.Tests/Utils/GenericTypeUtilTests.cs similarity index 70% rename from test/Soenneker.Utils.AutoBogus.Tests/GenericTypeUtilTests.cs rename to test/Soenneker.Utils.AutoBogus.Tests/Utils/GenericTypeUtilTests.cs index 7247568..4e1e618 100644 --- a/test/Soenneker.Utils.AutoBogus.Tests/GenericTypeUtilTests.cs +++ b/test/Soenneker.Utils.AutoBogus.Tests/Utils/GenericTypeUtilTests.cs @@ -3,18 +3,16 @@ using Soenneker.Utils.AutoBogus.Tests.Dtos.Complex; using Xunit; -namespace Soenneker.Utils.AutoBogus.Tests; +namespace Soenneker.Utils.AutoBogus.Tests.Utils; public class GenericTypeUtilTests { [Fact] public void Generate_should_generate() { - IAutoFaker faker = new AutoFaker(); + var faker = new AutoFaker(); var order1 = faker.Generate(); order1.Should().NotBeNull(); - - //var order2 = faker.Generate(); } } \ No newline at end of file