public void ThenShouldReturnReversedBytesBeginningWithNullGivenComputerArchitectureIsBigEndianAndAddNullTrue() { // Arrange var converter = new ExifBitConverter(new BigEndianComputerArchitectureInfoFake()); // Act var bytes = converter.GetBytes("Hello", true); // Assert Assert.That(bytes, Is.EqualTo(new[] { 0x0, 0x6f, 0x6c, 0x6c, 0x65, 0x48 })); }
public void ThenShouldReverseByteArrayGivenComputerArchitectureIsBigEndian() { // Arrange var converter = new ExifBitConverter(new BigEndianComputerArchitectureInfoFake()); // Act var bytes = converter.GetBytes("Hello", false); // Assert Assert.That(bytes, Is.EqualTo(new[] { 0x6f, 0x6c, 0x6c, 0x65, 0x48 })); }
public void ThenShouldReturnBytesPlusNullGivenComputerArchitectureIsLittleEndianAndAddNullTrue() { // Arrange var converter = new ExifBitConverter(new LittleEndianComputerArchitectureInfoFake()); // Act var bytes = converter.GetBytes("Hello", true); // Assert Assert.That(bytes, Is.EqualTo(new[] { 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x0 })); }
public void ResolutionIsApplied() { int i = 0; byte[] bytes = new ExifBitConverter().IsLittleEndian() ? new byte[] { 144, 1, 0, 0, 1, 0, 0, 0 } : new byte[] { 0, 0, 0, 1, 0, 0, 1, 144 }; int horizontalKey = (int)ExifPropertyTag.XResolution; int verticalKey = (int)ExifPropertyTag.YResolution; foreach (ImageFactory imageFactory in this.ListInputImagesWithMetadata()) { Image original = (Image)imageFactory.Image.Clone(); imageFactory.Resolution(400, 400); AssertionHelpers.AssertImagesAreDifferent(original, imageFactory.Image, "because the resolution operation should have been applied on {0}", imageFactory.ImagePath); Assert.AreEqual(400, imageFactory.Image.HorizontalResolution); Assert.AreEqual(400, imageFactory.Image.VerticalResolution); if (imageFactory.PreserveExifData && imageFactory.ExifPropertyItems.Any()) { if (imageFactory.ExifPropertyItems.ContainsKey(horizontalKey) && imageFactory.ExifPropertyItems.ContainsKey(verticalKey)) { PropertyItem horizontal = imageFactory.ExifPropertyItems[horizontalKey]; PropertyItem vertical = imageFactory.ExifPropertyItems[verticalKey]; Assert.AreEqual(bytes, horizontal.Value); Assert.AreEqual(bytes, vertical.Value); } } imageFactory.Format(new JpegFormat()).Save("./output/resolution-" + i++ + ".jpg"); } }