public void CreateForPropertyReturnsValueFromLamda() { var propertyInfo = typeof(Person).GetProperty(nameof(Person.FirstName)) !; var expected = Guid.NewGuid().ToString(); var sut = new ExpressionCreationRule <Person>(x => x.FirstName, () => expected, Environment.TickCount); var actual = sut.Create(null !, propertyInfo); actual.Should().Be(expected); }
public static IBuildConfiguration AddCreationRule <T>(this IBuildConfiguration configuration, Expression <Func <T, object?> > expression, object value, int priority) { configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); expression = expression ?? throw new ArgumentNullException(nameof(expression)); var rule = new ExpressionCreationRule <T>(expression, value, priority); configuration.CreationRules.Add(rule); return(configuration); }