public void GetEditValue_ShouldReturnLocationNullForIncompleteAddressField(bool isRequired) { /* * A partial address (missing values for some of the minimal fields) should not * attempt to find/create a Location Record, and therefore should not return * Location.Guid. In other words, GetEditValue should not enforce validation rules. * This will allow the the UI should show a Validation Message instead. */ var addressFieldType = new AddressFieldType(); var addressControl = new Rock.Web.UI.Controls.AddressControl(); /* The IsRequired setting on AddressControl should not affect how GetEditValue works. * IsRequired should be enforced by UI, not GetEditValue. */ addressControl.Required = isRequired; addressControl.Street1 = "100 Sesame Street"; addressControl.City = ""; addressControl.State = ""; addressControl.PostalCode = ""; addressControl.Country = ""; var configurationValues = new Dictionary <string, ConfigurationValue>(); var editValue = addressFieldType.GetEditValue(addressControl, configurationValues); var locationGuid = editValue.AsGuidOrNull(); Assert.That.IsNull(locationGuid); }
public void GetEditValue_ShouldReturnLocationNullForBlankAddressField(bool isRequired) { var addressFieldType = new AddressFieldType(); var addressControl = new Rock.Web.UI.Controls.AddressControl(); /* The IsRequired setting on AddressControl should not affect how GetEditValue works. * IsRequired should be enforced by UI, not GetEditValue. */ addressControl.Required = isRequired; addressControl.Street1 = ""; addressControl.City = ""; addressControl.State = ""; addressControl.PostalCode = ""; addressControl.Country = ""; var configurationValues = new Dictionary <string, ConfigurationValue>(); var editValue = addressFieldType.GetEditValue(addressControl, configurationValues); var locationGuid = editValue.AsGuidOrNull(); Assert.That.IsNull(locationGuid); }