public void PriorityFilterNodeDefaults() { PriorityFilterNode filter = new PriorityFilterNode(); Assert.AreEqual("Priority Filter", filter.Name); Assert.IsNull(filter.MinimumPriority); }
public void MinimumPriotityGreaterThanMaximumPriorityResultsInValidationError() { PriorityFilterMaximumPriorityValidationAttribute maxPrioValidation = new PriorityFilterMaximumPriorityValidationAttribute(); PriorityFilterNode prioFilterNode = new PriorityFilterNode(); prioFilterNode.MaximumPriority = 4; prioFilterNode.MinimumPriority = 8; List<ValidationError> validationErrors = new List<ValidationError>(); maxPrioValidation.Validate(prioFilterNode, typeof(PriorityFilterNode).GetProperty("MaximumPriority"), validationErrors, ServiceProvider); Assert.AreEqual(1, validationErrors.Count); }
/// <summary> /// Validate the given <paramref name="instance"/> and the <paramref name="propertyInfo"/>. /// </summary> /// <param name="instance"> /// The instance to validate. /// </param> /// <param name="propertyInfo"> /// The property containing the value to validate. /// </param> /// <param name="errors"> /// The collection to add any errors that occur during the validation. /// </param> protected override void ValidateCore(object instance, System.Reflection.PropertyInfo propertyInfo, IList <ValidationError> errors) { PriorityFilterNode node = instance as PriorityFilterNode; if (node != null) { if (node.MaximumPriority != null && node.MinimumPriority >= node.MaximumPriority) { string errorMessage = string.Format(CultureInfo.CurrentUICulture, Resources.MaxPrioShouldBeGreaterThanMinPrioError); errors.Add(new ValidationError(node, propertyInfo.Name, errorMessage)); } } }
public void PriorityFilterNodeTest() { string name = "some name"; int minimumPriority = 123; int maximumPriority = Int32.MaxValue; PriorityFilterNode node = new PriorityFilterNode(); node.Name = name; node.MaximumPriority = maximumPriority; node.MinimumPriority = minimumPriority; PriorityFilterData nodeData = (PriorityFilterData) node.LogFilterData; Assert.AreEqual(name, nodeData.Name); Assert.AreEqual(minimumPriority, nodeData.MinimumPriority); Assert.AreEqual(Int32.MaxValue, nodeData.MaximumPriority); }
public void PriorityFilterDataTest() { string name = "some name"; int minimumPriority = 123; int maximumPriority = 234; PriorityFilterData data = new PriorityFilterData(); data.Name = name; data.MinimumPriority = minimumPriority; data.MaximumPriority = maximumPriority; PriorityFilterNode node = new PriorityFilterNode(data); Assert.AreEqual(name, node.Name); Assert.AreEqual(minimumPriority, node.MinimumPriority); Assert.AreEqual(maximumPriority, node.MaximumPriority); }