public virtual void TestAddingMultipleSegments()
 {
     JpegSegmentData segmentData = new JpegSegmentData();
     sbyte segmentMarker1 = unchecked((sbyte)12);
     sbyte segmentMarker2 = unchecked((sbyte)21);
     sbyte[] segmentBytes1 = new sbyte[] { 1, 2, 3 };
     sbyte[] segmentBytes2 = new sbyte[] { 3, 2, 1 };
     segmentData.AddSegment(segmentMarker1, segmentBytes1);
     segmentData.AddSegment(segmentMarker2, segmentBytes2);
     Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(segmentMarker1));
     Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(segmentMarker2));
     NUnit.Framework.CollectionAssert.AreEqual(segmentBytes1, segmentData.GetSegment(segmentMarker1));
     NUnit.Framework.CollectionAssert.AreEqual(segmentBytes2, segmentData.GetSegment(segmentMarker2));
 }
示例#2
0
        public virtual void TestAddingMultipleSegments()
        {
            JpegSegmentData segmentData    = new JpegSegmentData();
            sbyte           segmentMarker1 = unchecked ((sbyte)12);
            sbyte           segmentMarker2 = unchecked ((sbyte)21);

            sbyte[] segmentBytes1 = new sbyte[] { 1, 2, 3 };
            sbyte[] segmentBytes2 = new sbyte[] { 3, 2, 1 };
            segmentData.AddSegment(segmentMarker1, segmentBytes1);
            segmentData.AddSegment(segmentMarker2, segmentBytes2);
            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(segmentMarker1));
            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(segmentMarker2));
            NUnit.Framework.CollectionAssert.AreEqual(segmentBytes1, segmentData.GetSegment(segmentMarker1));
            NUnit.Framework.CollectionAssert.AreEqual(segmentBytes2, segmentData.GetSegment(segmentMarker2));
        }
示例#3
0
        public virtual void TestRemoveSegment()
        {
            JpegSegmentData segmentData   = new JpegSegmentData();
            sbyte           segmentMarker = unchecked ((sbyte)12);

            sbyte[] segmentBytes1 = new sbyte[] { 1, 2, 3 };
            sbyte[] segmentBytes2 = new sbyte[] { 3, 2, 1 };
            segmentData.AddSegment(segmentMarker, segmentBytes1);
            segmentData.AddSegment(segmentMarker, segmentBytes2);
            Sharpen.Tests.AreEqual(2, segmentData.GetSegmentCount(segmentMarker));
            Sharpen.Tests.IsTrue(segmentData.ContainsSegment(segmentMarker));
            NUnit.Framework.CollectionAssert.AreEqual(segmentBytes1, segmentData.GetSegment(segmentMarker, 0));
            segmentData.RemoveSegment(segmentMarker);
            Sharpen.Tests.IsTrue(!segmentData.ContainsSegment(segmentMarker));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(segmentMarker));
        }
 public virtual void TestAddAndGetSegment()
 {
     JpegSegmentData segmentData = new JpegSegmentData();
     sbyte segmentMarker = unchecked((sbyte)12);
     sbyte[] segmentBytes = new sbyte[] { 1, 2, 3 };
     segmentData.AddSegment(segmentMarker, segmentBytes);
     Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(segmentMarker));
     NUnit.Framework.CollectionAssert.AreEqual(segmentBytes, segmentData.GetSegment(segmentMarker));
 }
示例#5
0
        public virtual void TestAddAndGetSegment()
        {
            JpegSegmentData segmentData   = new JpegSegmentData();
            sbyte           segmentMarker = unchecked ((sbyte)12);

            sbyte[] segmentBytes = new sbyte[] { 1, 2, 3 };
            segmentData.AddSegment(segmentMarker, segmentBytes);
            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(segmentMarker));
            NUnit.Framework.CollectionAssert.AreEqual(segmentBytes, segmentData.GetSegment(segmentMarker));
        }
		public virtual void TestSegmentWithMultipleOccurrences()
		{
			JpegSegmentData segmentData = new JpegSegmentData();
			sbyte segmentMarker = unchecked((sbyte)12);
			sbyte[] segmentBytes1 = new sbyte[] { 1, 2, 3 };
			sbyte[] segmentBytes2 = new sbyte[] { 3, 2, 1 };
			segmentData.AddSegment(segmentMarker, segmentBytes1);
			segmentData.AddSegment(segmentMarker, segmentBytes2);
			Sharpen.Tests.AreEqual(2, segmentData.GetSegmentCount(segmentMarker));
			NUnit.Framework.CollectionAssert.AreEqual(segmentBytes1, segmentData.GetSegment(segmentMarker));
			NUnit.Framework.CollectionAssert.AreEqual(segmentBytes1, segmentData.GetSegment(segmentMarker, 0));
			NUnit.Framework.CollectionAssert.AreEqual(segmentBytes2, segmentData.GetSegment(segmentMarker, 1));
		}
示例#7
0
        public virtual void TestSegmentWithMultipleOccurrences()
        {
            JpegSegmentData segmentData   = new JpegSegmentData();
            sbyte           segmentMarker = unchecked ((sbyte)12);

            sbyte[] segmentBytes1 = new sbyte[] { 1, 2, 3 };
            sbyte[] segmentBytes2 = new sbyte[] { 3, 2, 1 };
            segmentData.AddSegment(segmentMarker, segmentBytes1);
            segmentData.AddSegment(segmentMarker, segmentBytes2);
            Sharpen.Tests.AreEqual(2, segmentData.GetSegmentCount(segmentMarker));
            NUnit.Framework.CollectionAssert.AreEqual(segmentBytes1, segmentData.GetSegment(segmentMarker));
            NUnit.Framework.CollectionAssert.AreEqual(segmentBytes1, segmentData.GetSegment(segmentMarker, 0));
            NUnit.Framework.CollectionAssert.AreEqual(segmentBytes2, segmentData.GetSegment(segmentMarker, 1));
        }
 public virtual void TestRemoveSegment()
 {
     JpegSegmentData segmentData = new JpegSegmentData();
     sbyte segmentMarker = unchecked((sbyte)12);
     sbyte[] segmentBytes1 = new sbyte[] { 1, 2, 3 };
     sbyte[] segmentBytes2 = new sbyte[] { 3, 2, 1 };
     segmentData.AddSegment(segmentMarker, segmentBytes1);
     segmentData.AddSegment(segmentMarker, segmentBytes2);
     Sharpen.Tests.AreEqual(2, segmentData.GetSegmentCount(segmentMarker));
     Sharpen.Tests.IsTrue(segmentData.ContainsSegment(segmentMarker));
     NUnit.Framework.CollectionAssert.AreEqual(segmentBytes1, segmentData.GetSegment(segmentMarker, 0));
     segmentData.RemoveSegment(segmentMarker);
     Sharpen.Tests.IsTrue(!segmentData.ContainsSegment(segmentMarker));
     Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(segmentMarker));
 }
示例#9
0
        public virtual void TestReadSpecificSegments()
        {
            JpegSegmentData segmentData = JpegSegmentReader.ReadSegments(new FilePath("Tests/Data/withExifAndIptc.jpg"), Arrays.AsList(JpegSegmentType.App0, JpegSegmentType.App2).AsIterable());

            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(JpegSegmentType.App0));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App1));
            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(JpegSegmentType.App2));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appd));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appe));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App3));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App4));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App5));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App6));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App7));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App8));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App9));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appa));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appb));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appc));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appf));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Com));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Dht));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Sof0));
            NUnit.Framework.CollectionAssert.AreEqual(FileUtil.ReadBytes("Tests/Data/withExifAndIptc.jpg.app0"), segmentData.GetSegment(JpegSegmentType.App0));
            NUnit.Framework.CollectionAssert.AreEqual(FileUtil.ReadBytes("Tests/Data/withExifAndIptc.jpg.app2"), segmentData.GetSegment(JpegSegmentType.App2));
        }
示例#10
0
        public virtual void TestReadAllSegments()
        {
            JpegSegmentData segmentData = JpegSegmentReader.ReadSegments(new FilePath("Tests/Data/withExifAndIptc.jpg"), null);

            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(JpegSegmentType.App0));
            NUnit.Framework.CollectionAssert.AreEqual(FileUtil.ReadBytes("Tests/Data/withExifAndIptc.jpg.app0"), segmentData.GetSegment(JpegSegmentType.App0));
            NUnit.Framework.Assert.IsNull(segmentData.GetSegment(JpegSegmentType.App0, 1));
            Sharpen.Tests.AreEqual(2, segmentData.GetSegmentCount(JpegSegmentType.App1));
            NUnit.Framework.CollectionAssert.AreEqual(FileUtil.ReadBytes("Tests/Data/withExifAndIptc.jpg.app1.0"), segmentData.GetSegment(JpegSegmentType.App1, 0));
            NUnit.Framework.CollectionAssert.AreEqual(FileUtil.ReadBytes("Tests/Data/withExifAndIptc.jpg.app1.1"), segmentData.GetSegment(JpegSegmentType.App1, 1));
            NUnit.Framework.Assert.IsNull(segmentData.GetSegment(JpegSegmentType.App1, 2));
            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(JpegSegmentType.App2));
            NUnit.Framework.CollectionAssert.AreEqual(FileUtil.ReadBytes("Tests/Data/withExifAndIptc.jpg.app2"), segmentData.GetSegment(JpegSegmentType.App2));
            NUnit.Framework.Assert.IsNull(segmentData.GetSegment(JpegSegmentType.App2, 1));
            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(JpegSegmentType.Appd));
            NUnit.Framework.CollectionAssert.AreEqual(FileUtil.ReadBytes("Tests/Data/withExifAndIptc.jpg.appd"), segmentData.GetSegment(JpegSegmentType.Appd));
            NUnit.Framework.Assert.IsNull(segmentData.GetSegment(JpegSegmentType.Appd, 1));
            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(JpegSegmentType.Appe));
            NUnit.Framework.CollectionAssert.AreEqual(FileUtil.ReadBytes("Tests/Data/withExifAndIptc.jpg.appe"), segmentData.GetSegment(JpegSegmentType.Appe));
            NUnit.Framework.Assert.IsNull(segmentData.GetSegment(JpegSegmentType.Appe, 1));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App3));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App4));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App5));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App6));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App7));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App8));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.App9));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appa));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appb));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appc));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Appf));
            Sharpen.Tests.AreEqual(0, segmentData.GetSegmentCount(JpegSegmentType.Com));
            Sharpen.Tests.AreEqual(4, segmentData.GetSegmentCount(JpegSegmentType.Dht));
            Sharpen.Tests.AreEqual(2, segmentData.GetSegmentCount(JpegSegmentType.Dqt));
            Sharpen.Tests.AreEqual(1, segmentData.GetSegmentCount(JpegSegmentType.Sof0));
            NUnit.Framework.Assert.IsNull(segmentData.GetSegment(JpegSegmentType.App3, 0));
        }