Exemplo n.º 1
0
        public void ExifSignedRationalArrayTests(ExifTag tag)
        {
            SignedRational[] expected = new[] { new SignedRational(21, 42) };
            ExifValue        value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifSignedRationalArray)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 2
0
        public void ExifUndefinedArrayTests(ExifTag tag)
        {
            byte[]    expected = new[] { byte.MaxValue };
            ExifValue value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifByteArray)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 3
0
        public void ExifStringTests(ExifTag tag)
        {
            const string expected = "ImageSharp";
            ExifValue    value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(0M));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifString)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 4
0
        public void ExifNumberArrayTests(ExifTag tag)
        {
            Number[]  expected = new[] { new Number(uint.MaxValue) };
            ExifValue value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifNumberArray)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 5
0
        public void ExifShortArrayTests(ExifTag tag)
        {
            ushort[]  expected = new[] { ushort.MaxValue };
            ExifValue value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifShortArray)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 6
0
        public void ExifLongTests(ExifTag tag)
        {
            const uint expected = uint.MaxValue;
            ExifValue  value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifLong)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 7
0
        public void ExifUndefinedTests(ExifTag tag)
        {
            const byte expected = byte.MaxValue;
            ExifValue  value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue((int)expected));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifByte)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 8
0
        public void ExifRationalTests(ExifTag tag)
        {
            var       expected = new Rational(21, 42);
            ExifValue value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue(new SignedRational(expected.ToDouble())));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifRational)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 9
0
        public void ExifShortTests(ExifTag tag)
        {
            const ushort expected = (ushort)short.MaxValue;
            ExifValue    value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue((int)expected));
            Assert.True(value.TrySetValue((short)expected));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifShort)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 10
0
        public void ExifNumberTests(ExifTag tag)
        {
            Number    expected = ushort.MaxValue;
            ExifValue value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue((uint)expected));
            Assert.True(value.TrySetValue((int)expected));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifNumber)value;

            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 11
0
        public void ExifUcs2StringTests(ExifTag tag)
        {
            const string expected = "Dan Petitt";
            ExifValue    value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(123));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifUcs2String)value;

            Assert.Equal(expected, typed.Value);

            Assert.True(value.TrySetValue(Encoding.GetEncoding("UCS-2").GetBytes(expected)));
            Assert.Equal(expected, typed.Value);
        }
Exemplo n.º 12
0
        public void ExifNumberArrayTests(ExifTag tag)
        {
            Number[]  expected = new[] { new Number(uint.MaxValue) };
            ExifValue value    = ExifValues.Create(tag);

            Assert.False(value.TrySetValue(expected.ToString()));
            Assert.True(value.TrySetValue(expected));

            var typed = (ExifNumberArray)value;

            Assert.Equal(expected, typed.Value);

            Assert.True(value.TrySetValue(int.MaxValue));
            Assert.Equal(new[] { (Number)int.MaxValue }, value.GetValue());

            Assert.True(value.TrySetValue(new[] { 1u, 2u, 5u }));
            Assert.Equal(new[] { (Number)1u, (Number)2u, (Number)5u }, value.GetValue());

            Assert.True(value.TrySetValue(new[] { (short)1, (short)2, (short)5 }));
            Assert.Equal(new[] { (Number)(short)1, (Number)(short)2, (Number)(short)5 }, value.GetValue());
        }
Exemplo n.º 13
0
        public void ExifEncodedStringTests(ExifTag tag)
        {
            foreach (object code in Enum.GetValues(typeof(EncodedString.CharacterCode)))
            {
                var charCode = (EncodedString.CharacterCode)code;

                Assert.Equal(ExifEncodedStringHelpers.CharacterCodeBytesLength, ExifEncodedStringHelpers.GetCodeBytes(charCode).Length);

                const string expectedText = "test string";
                var          expected     = new EncodedString(charCode, expectedText);
                ExifValue    value        = ExifValues.Create(tag);

                Assert.False(value.TrySetValue(123));
                Assert.True(value.TrySetValue(expected));

                var typed = (ExifEncodedString)value;
                Assert.Equal(expected, typed.Value);
                Assert.Equal(expectedText, (string)typed.Value);
                Assert.Equal(charCode, typed.Value.Code);
            }
        }