public void ValidationTests() { PropertyType propertyType = new PropertyTypeBuilder() .WithAlias("prop") .WithSupportsPublishing(true) .Build(); var prop = new Property(propertyType); prop.SetValue("a"); Assert.AreEqual("a", prop.GetValue()); Assert.IsNull(prop.GetValue(published: true)); PropertyValidationService propertyValidationService = GetPropertyValidationService(); Assert.IsTrue(propertyValidationService.IsPropertyValid(prop)); propertyType.Mandatory = true; Assert.IsTrue(propertyValidationService.IsPropertyValid(prop)); prop.SetValue(null); Assert.IsFalse(propertyValidationService.IsPropertyValid(prop)); // can publish, even though invalid prop.PublishValues(); }
public void ValidationTests() { var propertyType = new PropertyType("editor", ValueStorageType.Nvarchar) { Alias = "prop", SupportsPublishing = true }; var prop = new Property(propertyType); prop.SetValue("a"); Assert.AreEqual("a", prop.GetValue()); Assert.IsNull(prop.GetValue(published: true)); var propertyValidationService = new PropertyValidationService( Current.Factory.GetInstance <PropertyEditorCollection>(), Current.Factory.GetInstance <ServiceContext>().DataTypeService, Current.Factory.GetInstance <ServiceContext>().TextService); Assert.IsTrue(propertyValidationService.IsPropertyValid(prop)); propertyType.Mandatory = true; Assert.IsTrue(propertyValidationService.IsPropertyValid(prop)); prop.SetValue(null); Assert.IsFalse(propertyValidationService.IsPropertyValid(prop)); // can publish, even though invalid prop.PublishValues(); }