Skip to content

Commit

Permalink
Misc small improvement, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
soenneker committed Feb 13, 2024
1 parent 56c67df commit 757d687
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class OrderOverride : AutoFakerOverride<Order>
Then just add `AutoFakerOverride` to the `AutoFaker.Config` instance:

```csharp
autoFaker.Config.Overrides = new AutoFakerOverrides();
autoFaker.Config.Overrides = new List<AutoFakerGeneratorOverride>();
autoFaker.Config.Overrides.Add(new OrderOverride());
```

Expand Down
2 changes: 1 addition & 1 deletion src/AutoFaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public List<TType> Generate<TType>(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);

Check warning on line 69 in src/AutoFaker.cs

View workflow job for this annotation

GitHub Actions / publish-package

Dereference of a possibly null reference.

Check warning on line 69 in src/AutoFaker.cs

View workflow job for this annotation

GitHub Actions / publish-package

Dereference of a possibly null reference.
Expand Down
1 change: 1 addition & 0 deletions src/Services/CachedTypeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ internal static class CachedTypeService

internal static readonly Lazy<CachedType> IDictionary = new(() => CacheService.Cache.GetCachedType(typeof(IDictionary<,>)));
internal static readonly Lazy<CachedType> IEnumerable = new(() => CacheService.Cache.GetCachedType(typeof(IEnumerable<>)));
internal static readonly Lazy<CachedType> AutoFaker = new(() => CacheService.Cache.GetCachedType(typeof(AutoFaker)));
}
7 changes: 1 addition & 6 deletions test/Soenneker.Utils.AutoBogus.Tests/AutoFakerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ public void Generate_struct_should_generate()

var structObj = faker.Generate<TestStruct>();
structObj.Should().NotBeNull();

// product.Reviews.Count.Should().BeGreaterThan(0);
// product.
}

[Fact]
Expand All @@ -51,8 +48,6 @@ public void Generate_Product_should_generate()
var product = faker.Generate<Product>();
product.Should().NotBeNull();
product.GetRevisions.Should().NotBeNullOrEmpty();
// product.Reviews.Count.Should().BeGreaterThan(0);
// product.
}

[Fact]
Expand All @@ -75,7 +70,7 @@ public void Generate_many_int_should_generate()
{
var faker = new AutoFaker();

List<int> intList = new List<int>();
var intList = new List<int>();

for (var i = 0; i < 1000; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public AutoGenerateContextFixture()
_faker = new Faker();
_ruleSets = new List<string>();
_fakerConfig = new AutoFakerConfig();

//ConfigService.SetCustomConfig(_fakerConfig);
}

public class GenerateMany_Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Order>();
order1.Should().NotBeNull();

//var order2 = faker.Generate<Order>();
}
}

0 comments on commit 757d687

Please sign in to comment.