public void Should_Use_Custom_StringLength_Boundaries_for_String_Value_Injection() { //Create an instance of our test class var testInstance = new SimpleStringTestClass(); var stringLengthMax = 30; var stringLengthMin = 10; //Create an instance of our IntSelector and set some custom bounds var selector = new StringSelector().SetMax(() => stringLengthMax) .SetMin(() => stringLengthMin); //Iterate over the test object's properties foreach (var property in testInstance.GetType().GetProperties()) { Assert.IsTrue(selector.CanBind(property), string.Format("should have been able to bind to property {0}", property.Name)); //Inject the value into this property on our test instance class selector.Generate(testInstance, property); //Get the value out of the property var fieldValue = (string)property.GetValue(testInstance, null); Assert.IsNotNullOrEmpty(fieldValue); Assert.IsTrue(fieldValue.Length <= stringLengthMax && fieldValue.Length >= stringLengthMin, "Custom range should have worked"); } }
public void Should_Use_Custom_StringLength_Boundaries_for_String_Value_Injection() { //Create an instance of our test class var testInstance = new SimpleStringTestClass(); var stringLengthMax = 30; var stringLengthMin = 10; //Create an instance of our IntSelector and set some custom bounds var selector = new StringSelector().SetMax(() => stringLengthMax) .SetMin(() => stringLengthMin); //Iterate over the test object's properties foreach (var property in testInstance.GetType().GetProperties()) { Assert.IsTrue(selector.CanBind(property), string.Format("should have been able to bind to property {0}", property.Name)); //Inject the value into this property on our test instance class selector.Generate(testInstance, property); //Get the value out of the property var fieldValue = (string)property.GetValue(testInstance, null); Assert.IsNotNullOrEmpty(fieldValue); Assert.IsTrue(fieldValue.Length <= stringLengthMax && fieldValue.Length >= stringLengthMin, "Custom range should have worked"); } }