-
-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix setting property with private setter on base type (#390)
* Fix setting property with private setter on base type * Small refactoring: Breakup LINQ statement for debugability and better readability. Co-authored-by: Thomas Levesque <thomaslevesque@users.noreply.github.com> Co-authored-by: bchavez <bchavez@bitarmory.com>
- Loading branch information
1 parent
e8c1f45
commit ab05cc0
Showing
2 changed files
with
76 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Bogus.Tests.GitHubIssues | ||
{ | ||
public class Issue389 | ||
{ | ||
[Fact] | ||
public void property_with_private_setter_in_base_class_is_assigned() | ||
{ | ||
var foo = new Faker<Foo>() | ||
.RuleFor(f => f.PropInFoo, _ => 42) | ||
.RuleFor(f => f.PropInFooBase, _ => 123) | ||
.Generate(); | ||
|
||
foo.PropInFoo.Should().Be(42); | ||
foo.PropInFooBase.Should().Be(123); | ||
} | ||
|
||
public class FooBase | ||
{ | ||
public int PropInFooBase { get; private set; } | ||
} | ||
|
||
public class Foo : FooBase | ||
{ | ||
public int PropInFoo { get; private set; } | ||
} | ||
|
||
public class Zoo : Foo | ||
{ | ||
public int PropInZoo { get; private set; } | ||
} | ||
|
||
[Fact] | ||
public void property_with_private_setter_inheritance_chain_is_assigned() | ||
{ | ||
var zoo = new Faker<Zoo>() | ||
.RuleFor(f => f.PropInFoo, _ => 42) | ||
.RuleFor(f => f.PropInFooBase, _ => 123) | ||
.RuleFor(f => f.PropInZoo, _ => 77) | ||
.Generate(); | ||
|
||
zoo.PropInFoo.Should().Be(42); | ||
zoo.PropInFooBase.Should().Be(123); | ||
zoo.PropInZoo.Should().Be(77); | ||
} | ||
} | ||
} |
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