-
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
… method for weighted generation of null values.
- Loading branch information
Showing
4 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Linq; | ||
using Bogus.Extensions; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Bogus.Tests.GitHubIssues | ||
{ | ||
public class Issue178 : SeededTest | ||
{ | ||
[Fact] | ||
public void weighted_null_check() | ||
{ | ||
var f = new Faker(); | ||
var mostlyNull = Enumerable.Range(1, 100) | ||
.Select(n => (int?)n.OrNull(f, 0.9)) | ||
.Count( n => !n.HasValue); | ||
|
||
mostlyNull.Should().BeGreaterThan(80); | ||
|
||
|
||
var mostlyNotNull = Enumerable.Range(1, 100) | ||
.Select(n => (int?)n.OrNull(f, 0.1)) | ||
.Count(n => !n.HasValue); | ||
|
||
mostlyNotNull.Should().BeLessThan(20); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters