Skip to content

Instantly share code, notes, and snippets.

@emiaj
Last active December 12, 2015 04:08
Show Gist options
  • Select an option

  • Save emiaj/4712439 to your computer and use it in GitHub Desktop.

Select an option

Save emiaj/4712439 to your computer and use it in GitHub Desktop.
public class InputQueryModel : InputCommandModel
{
}
public class InputCommandModel
{
public string Name { get; set; }
}
[Test]
public void smoke()
{
var typeDescriptorCache = new TypeDescriptorCache();
var accessorRules = new AccessorRules();
accessorRules.Add<InputCommandModel>(x => x.Name, new RequiredFieldRule());
// GREEN, reports 1 element
typeDescriptorCache.GetPropertiesFor<InputCommandModel>()
.Select(keyValuePair => keyValuePair.Value)
.Select(property => new SingleProperty(property))
.SelectMany(accessorRules.AllRulesFor<IFieldValidationRule>)
.ShouldHaveCount(1);
}
public class InputQueryModel
{
public string Name { get; set; }
}
public class InputCommandModel : InputQueryModel
{
}
[Test]
public void smoke()
{
var typeDescriptorCache = new TypeDescriptorCache();
var accessorRules = new AccessorRules();
accessorRules.Add<InputCommandModel>(x => x.Name, new RequiredFieldRule());
// RED, reports 0 elements
typeDescriptorCache.GetPropertiesFor<InputCommandModel>()
.Select(keyValuePair => keyValuePair.Value)
.Select(property => new SingleProperty(property))
.SelectMany(accessorRules.AllRulesFor<IFieldValidationRule>)
.ShouldHaveCount(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment