-
-
Notifications
You must be signed in to change notification settings - Fork 892
Expand file tree
/
Copy pathJpegMetadataTests.cs
More file actions
82 lines (61 loc) · 2.06 KB
/
JpegMetadataTests.cs
File metadata and controls
82 lines (61 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.Collections.ObjectModel;
using SixLabors.ImageSharp.Formats.Jpeg;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg;
[Trait("Format", "Jpg")]
public class JpegMetadataTests
{
[Fact]
public void CloneIsDeep()
{
JpegMetadata meta = new() { ColorType = JpegColorType.Luminance };
JpegMetadata clone = (JpegMetadata)meta.DeepClone();
clone.ColorType = JpegColorType.YCbCrRatio420;
Assert.False(meta.ColorType.Equals(clone.ColorType));
}
[Fact]
public void Quality_DefaultQuality()
{
JpegMetadata meta = new();
Assert.Equal(meta.Quality, ImageSharp.Formats.Jpeg.Components.Quantization.DefaultQualityFactor);
}
[Fact]
public void Quality_LuminanceOnlyQuality()
{
int quality = 50;
JpegMetadata meta = new() { LuminanceQuality = quality };
Assert.Equal(meta.Quality, quality);
}
[Fact]
public void Quality_BothComponentsQuality()
{
int quality = 50;
JpegMetadata meta = new() { LuminanceQuality = quality, ChrominanceQuality = quality };
Assert.Equal(meta.Quality, quality);
}
[Fact]
public void Quality_ReturnsMaxQuality()
{
int qualityLuma = 50;
int qualityChroma = 30;
JpegMetadata meta = new() { LuminanceQuality = qualityLuma, ChrominanceQuality = qualityChroma };
Assert.Equal(meta.Quality, qualityLuma);
}
[Fact]
public void Comment_EmptyComment()
{
JpegMetadata meta = new();
Assert.True(Array.Empty<JpegComData>().SequenceEqual(meta.Comments));
}
[Fact]
public void Comment_OnlyComment()
{
string comment = "test comment";
Collection<string> expectedCollection = [comment];
JpegMetadata meta = new();
meta.Comments.Add(JpegComData.FromString(comment));
Assert.Equal(1, meta.Comments.Count);
Assert.True(expectedCollection.FirstOrDefault() == meta.Comments.FirstOrDefault().ToString());
}
}