Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/Bogus.Tests/Bogus.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="morelinq" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="PolySharp" Version="1.15.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Rant" Version="3.0.530" />
<PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.39" />
<PackageReference Include="Verify.Xunit" Version="22.8.0" />
Expand Down
22 changes: 22 additions & 0 deletions Source/Bogus.Tests/RecordTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using FluentAssertions;
using Xunit;

namespace Bogus.Tests;

public class RecordTest
{
private record User(string FirstName, string Email, string LastName);

[Fact]
public void Can_generate_a_record()
{
var faker = new Faker<User>()
.RuleFor(d => d.FirstName, f => f.Person.FirstName)
.RuleFor(d => d.LastName, _ => "x");

var user = faker.Generate();
user.FirstName.Should().NotBeNull();
user.LastName.Should().Be("x");
user.Email.Should().BeNull();
}
}
6 changes: 5 additions & 1 deletion Source/Bogus/Faker[T].cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ public Faker(string locale = "en", IBinder binder = null)
this.Locale = locale;
FakerHub = new Faker(locale);
TypeProperties = this.binder.GetMembers(typeof(T));
this.CreateActions[Default] = faker => Activator.CreateInstance<T>();
this.CreateActions[Default] = faker =>
{
var constructor = typeof(T).GetConstructors().First();
return (T)constructor.Invoke(new object[constructor.GetParameters().Length]);
};
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions Source/Bogus/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
[assembly: AssemblyProduct("Bogus")]
[assembly: AssemblyTitle("Bogus Fake Data Generator for .NET")]
[assembly: AssemblyCompany("Brian Chavez")]
[assembly: AssemblyCopyright("Brian Chavez © 2015")]
[assembly: AssemblyCopyright("Brian Chavez © 2025")]
[assembly: AssemblyVersion("0.0.0")]
[assembly: AssemblyFileVersion("0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-localbuild built on 2015-01-01 00:00:00Z")]
[assembly: AssemblyInformationalVersion("0.0.0-localbuild built on 2025-06-24 13:41:48Z")]
[assembly: AssemblyTrademark("MIT License")]
[assembly: AssemblyDescription("https://github.com/bchavez/Bogus")]
[assembly: InternalsVisibleTo("Bogus.Tests")]
Expand All @@ -18,10 +18,10 @@ internal static class AssemblyVersionInformation {
internal const System.String AssemblyProduct = "Bogus";
internal const System.String AssemblyTitle = "Bogus Fake Data Generator for .NET";
internal const System.String AssemblyCompany = "Brian Chavez";
internal const System.String AssemblyCopyright = "Brian Chavez © 2015";
internal const System.String AssemblyCopyright = "Brian Chavez © 2025";
internal const System.String AssemblyVersion = "0.0.0";
internal const System.String AssemblyFileVersion = "0.0.0";
internal const System.String AssemblyInformationalVersion = "0.0.0-localbuild built on 2015-01-01 00:00:00Z";
internal const System.String AssemblyInformationalVersion = "0.0.0-localbuild built on 2025-06-24 13:41:48Z";
internal const System.String AssemblyTrademark = "MIT License";
internal const System.String AssemblyDescription = "https://github.com/bchavez/Bogus";
internal const System.String InternalsVisibleTo = "Bogus.Tests";
Expand Down