public void picture_validator_should_change_picture_name_on_duplicate() { var duplicatedNames = new List <Picture> { new Picture { Name = "Name1" }, new Picture { Name = "Name1" }, new Picture { Name = "Name2" }, new Picture { Name = "Name2" }, new Picture { Name = "Name3" }, }; var pictureVal = new PictureValidator(); pictureVal.Validate(duplicatedNames); var isAnyDuplicated = duplicatedNames .GroupBy(x => x.Name) .Where(x => x.Count() > 1) .ToList(); isAnyDuplicated.Should().BeEmpty(); }
/// <summary> /// Assign this Picture Type from a Validator /// </summary> private void AssignFromValidator(PictureValidator validator) { System.Diagnostics.Debug.Assert(validator != null); if (validator.IsValid()) { this.IsSigned = validator.ValidationContext.HaveSign; this.Scale = validator.ValidationContext.Scale; this.Digits = validator.ValidationContext.Digits; this.RealDigits = validator.ValidationContext.RealDigits; this.IsSigned = validator.ValidationContext.HaveSign; this.Category = validator.ValidationContext.Category; this.IsExternalFloat = validator.ValidationContext.IsExternalFloatSequence(); this.Sequence = validator.ValidationContext.Sequence.ToArray(); this.Size = validator.ValidationContext.Size; if (validator.ValidationContext.IsDbcsSequence()) { Category = PictureCategory.Dbcs; } if (this.IsExternalFloat) { Category = PictureCategory.ExternalFloat; } } else { Category = PictureCategory.Error; } }
public bool IsValid() { var validation = new PictureValidator(); var result = validation.Validate(this); ValidationErrors = result.Errors; return(result.IsValid); }
/// <summary> /// La cañería recibe una imagen, y envía por una cañería dependiendo de si la imagen contiene una cara o no. /// </summary> /// <param name="nextPipe">Siguiente cañeria si contiene una cara</param> /// <param name="next2Pipe">Siguiente cañeria si no contiene una cara</param> public PipeConditionalBifurcation(IPipe nextPipe, IPipe next2Pipe) { this.next2Pipe = next2Pipe; this.nextPipe = nextPipe; this.pictureValidator = new PictureValidator(); }
/// <summary> /// Validator constructor. /// </summary> /// <param name="validator"></param> public PictureType(PictureValidator validator) : base(Tags.Picture) { AssignFromValidator(validator); }
public override ValidationResult IsValid() { var validator = new PictureValidator(); return(validator.Validate(Image)); }