-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated RelativeValueGenerator to support ExpandoObject context values
Updated DefaultExecuteStrategy to use a temporary ExpandoObject to enable parameter dependent value generation
- Loading branch information
1 parent
64852eb
commit 03af4ee
Showing
4 changed files
with
350 additions
and
127 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
ModelBuilder.UnitTests/Scenarios/RelativeDataGenerationTests.cs
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,45 @@ | ||
namespace ModelBuilder.UnitTests.Scenarios | ||
{ | ||
using System.Diagnostics.CodeAnalysis; | ||
using FluentAssertions; | ||
using ModelBuilder.Data; | ||
using ModelBuilder.UnitTests.Models; | ||
using Xunit; | ||
|
||
public class RelativeDataGenerationTests | ||
{ | ||
[Fact] | ||
[SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", | ||
Justification = "Emails are lower-case by convention")] | ||
public void AssignsPropertyValuesRelativeToOtherPropertyValues() | ||
{ | ||
var actual = Model.Create<Person>(); | ||
|
||
var expected = (actual.FirstName + "." + actual.LastName + "@").ToLowerInvariant(); | ||
|
||
actual.PersonalEmail.Should() | ||
.StartWith(expected); | ||
} | ||
|
||
[Fact] | ||
[SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", | ||
Justification = "Emails are lower-case by convention")] | ||
public void CreatesParameterValuesRelativeToOtherParameterValues() | ||
{ | ||
var actual = Model.Create<OrderedConstructorParameters>(); | ||
|
||
if (actual.Gender == Gender.Female) | ||
{ | ||
TestData.FemaleNames.Should().Contain(actual.FirstName); | ||
} | ||
else | ||
{ | ||
TestData.MaleNames.Should().Contain(actual.FirstName); | ||
} | ||
|
||
var expectedEmail = (actual.FirstName + "." + actual.LastName + "@" + actual.Domain).ToLowerInvariant(); | ||
|
||
actual.Email.Should().StartWith(expectedEmail); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.