public void HandleShouldReturnNullForEmptyProperties(string propertyName) { var handler = new SimpleEnumerablePropertyTypePredicateHandler <FilterWithSimpleEnumerableProps, Entity>(); var property = typeof(FilterWithSimpleEnumerableProps).GetProperty(propertyName); var filter = new FilterWithSimpleEnumerableProps(); var result = handler.Handle(filter, property); Assert.Null(result); }
public void HandleShouldReturnExpectedResult(string propertyName) { var handler = new SimpleEnumerablePropertyTypePredicateHandler <FilterWithSimpleEnumerableProps, Entity>(); var property = typeof(FilterWithSimpleEnumerableProps).GetProperty(propertyName); var filter = new FilterWithSimpleEnumerableProps(); var underlyingType = property.PropertyType.GetEnumerableUnderlyingType(); var array = Array.CreateInstance(underlyingType, 1); array.Initialize(); property.SetValue(filter, array); var result = handler.Handle(filter, property); Assert.Matches($@"x => value\(.*\[\]\).Contains\(x\.{property.Name}\)", result.ToString()); }