public override int GetHashCode() { unchecked { var hashCode = ImageSizeRange.GetHashCode(); hashCode = (hashCode * 397) ^ SizeSpecificImageMaxSize.GetHashCode(); hashCode = (hashCode * 397) ^ MaxSize.GetHashCode(); hashCode = (hashCode * 397) ^ MaxFilenameLength.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = ImageSizeRange.GetHashCode(); hashCode = (hashCode * 397) ^ BinaryExists.GetHashCode(); hashCode = (hashCode * 397) ^ ValidImage.GetHashCode(); hashCode = (hashCode * 397) ^ ExtensionMatchContentFormat.GetHashCode(); hashCode = (hashCode * 397) ^ MaxSize.GetHashCode(); hashCode = (hashCode * 397) ^ MaxFilenameLength.GetHashCode(); return(hashCode); } }
public bool Equals(CompositeBitmapImageElementConstraints other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(ImageSizeRange.Equals(other.ImageSizeRange) && SizeSpecificImageMaxSize == other.SizeSpecificImageMaxSize && MaxSize == other.MaxSize && MaxFilenameLength == other.MaxFilenameLength && (ReferenceEquals(SupportedFileFormats, other.SupportedFileFormats) || SupportedFileFormats.SequenceEqual(other.SupportedFileFormats))); }
public bool Equals(ScalableBitmapImageElementConstraints other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(ImageSizeRange.Equals(other.ImageSizeRange) && BinaryExists == other.BinaryExists && ValidImage == other.ValidImage && MaxSize == other.MaxSize && MaxFilenameLength == other.MaxFilenameLength && (ReferenceEquals(SupportedFileFormats, other.SupportedFileFormats) || SupportedFileFormats.SequenceEqual(other.SupportedFileFormats))); }
public bool Equals(CompositeBitmapImageElementConstraints other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(ImageSizeRange.Equals(other.ImageSizeRange) && SizeSpecificImageMaxSize == other.SizeSpecificImageMaxSize && MaxSize == other.MaxSize && MaxFilenameLength == other.MaxFilenameLength && BinaryExists == other.BinaryExists && ValidImage == other.ValidImage && ExtensionMatchContentFormat == other.ExtensionMatchContentFormat && (ReferenceEquals(SupportedFileFormats, other.SupportedFileFormats) || SupportedFileFormats.SequenceEqual(other.SupportedFileFormats))); }
private static bool SizeRangeIsConsistent(ImageSizeRange range) { return(range.Min.Width < range.Max.Width && range.Min.Height < range.Max.Height && range.Min.Width > 0 && range.Min.Height > 0); }
public void ShouldDeserializeValidDescriptor() { const string JsonString = @"{ ""id"": 100500, ""versionId"": ""j;lkj:LK;jhHlkjhlI*Hljhlihl"", ""properties"": { ""foo"": ""bar"", ""baz"": 123 }, ""elements"": [{ ""type"": ""scalableBitmapImage"", ""templateCode"": 1, ""properties"": { ""baz"": [ 321, 456 ], ""foo"": ""bar"" }, ""constraints"": { ""ru"": { ""supportedFileFormats"": [""png"", ""gif""], ""imageSizeRange"": { ""min"": { ""width"": 1, ""height"": 2 }, ""max"": { ""width"": 10, ""height"": 11 } } } } }] }"; var templateDescriptor = JsonConvert.DeserializeObject <ITemplateDescriptor>(JsonString, SerializerSettings.Default); Assert.NotNull(templateDescriptor); Assert.Equal(JObject.Parse(@"{""foo"": ""bar"", ""baz"": 123}"), templateDescriptor.Properties, new JTokenEqualityComparer()); Assert.Single(templateDescriptor.Elements); var element = templateDescriptor.Elements.First(); Assert.IsType <ElementDescriptor>(element); Assert.Equal(ElementDescriptorType.ScalableBitmapImage, element.Type); Assert.Equal(1, element.TemplateCode); Assert.Equal(JObject.Parse(@"{""foo"": ""bar"", ""baz"": [ 321, 456 ]}"), element.Properties, new JTokenEqualityComparer()); Assert.Single(element.Constraints); var constraintSetItem = element.Constraints.First <ConstraintSetItem>(); Assert.Equal(Language.Ru, constraintSetItem.Language); Assert.IsType <ScalableBitmapImageElementConstraints>(constraintSetItem.ElementConstraints); var constraints = (ScalableBitmapImageElementConstraints)constraintSetItem.ElementConstraints; Assert.Null(constraints.MaxSize); Assert.Null(constraints.MaxFilenameLength); Assert.Collection(constraints.SupportedFileFormats, x => Assert.Equal(FileFormat.Png, x), x => Assert.Equal(FileFormat.Gif, x)); var expectedSizeRange = new ImageSizeRange { Min = new ImageSize { Height = 2, Width = 1 }, Max = new ImageSize { Width = 10, Height = 11 } }; Assert.Equal(expectedSizeRange, constraints.ImageSizeRange); }