Skip to content

Commit

Permalink
add extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Nov 9, 2023
1 parent cccc672 commit 08360a9
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ private static double GetGeoLocationAltitude(List<Directory> allExifItems)
return (int) altitude;
}

private static double GetXmpGeoAlt(List<Directory> allExifItems)
internal static double GetXmpGeoAlt(List<Directory> allExifItems)
{
var altitudeRef = true;
var altitude = 0d;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System.Collections.Generic;
using MetadataExtractor;
using MetadataExtractor.Formats.Xmp;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using starsky.foundation.readmeta.ReadMetaHelpers;
using XmpCore.Impl;

namespace starskytest.starsky.foundation.readmeta.ReadMetaHelpers;

[TestClass]
public class ReadMetaExifTest
{
[TestMethod]
public void GetXmpGeoAlt_PositiveAltitude_ReturnsPositiveAltitude()
{
// Arrange
var dir2 = new XmpDirectory();
dir2.SetXmpMeta(new XmpMeta());
dir2.XmpMeta?.SetProperty("http://ns.adobe.com/exif/1.0/", "GPSAltitude","1/1" );
dir2.XmpMeta?.SetProperty("http://ns.adobe.com/exif/1.0/", "GPSAltitudeRef","0" );

var allExifItems = new List<Directory>
{
dir2
};

// Act
var result = ReadMetaExif.GetXmpGeoAlt(allExifItems);

// Assert
Assert.AreEqual(1, result, 0.001); // Use an appropriate tolerance
}

[TestMethod]
public void GetXmpGeoAlt_NegativeAltitude_ReturnsNegativeAltitude()
{
// Arrange
var dir2 = new XmpDirectory();
dir2.SetXmpMeta(new XmpMeta());
dir2.XmpMeta?.SetProperty("http://ns.adobe.com/exif/1.0/", "GPSAltitude","10/1" );
dir2.XmpMeta?.SetProperty("http://ns.adobe.com/exif/1.0/", "GPSAltitudeRef","1" );

var allExifItems = new List<Directory>
{
dir2
};

// Act
var result = ReadMetaExif.GetXmpGeoAlt(allExifItems);

// Assert
Assert.AreEqual(-10, result, 0.001); // Use an appropriate tolerance
}

[TestMethod]
public void GetXmpGeoAlt_ZeroAltitude_ReturnsZeroAltitude()
{
// Arrange
var dir2 = new XmpDirectory();
dir2.SetXmpMeta(new XmpMeta());
dir2.XmpMeta?.SetProperty("http://ns.adobe.com/exif/1.0/", "GPSAltitude","0/1" );
dir2.XmpMeta?.SetProperty("http://ns.adobe.com/exif/1.0/", "GPSAltitudeRef","1" );
var allExifItems = new List<Directory>
{
dir2
};

// Act
var result = ReadMetaExif.GetXmpGeoAlt(allExifItems);

// Assert
Assert.AreEqual(0, result, 0.001); // Use an appropriate tolerance
}

}

0 comments on commit 08360a9

Please sign in to comment.