Sample for validating tests

Hi,
I want sample code for my unit tests that convert from one format to all other formats include itself.
I want the check will:

  1. Check the number of layers for input and output file, number of features in layers, number of attributes and geometry type.
  2. By default GeoJsonDriver use SpatialReferenceSystem.Wgs84
    if input file have the same spatial reference system than output file’s coordinate should be the same.
    In other case you need transform coordinate depend on spatial reference system.
    Thank,

@danies8

To keep progress on this scenario (“Sample for validating tests Hi, I want sample code for my unit tests that convert from one format to all other formats include itself. I want the check will: 1. Check the number of layers for input and output file, number of features in layers, number of attributes and geometr…”), start by validating the hypothesis around All pages of Document are not Exported | DOCX to PDF Conversion using Java:

@tahir.manzoor
We are using license version of aspose(Aspose word version:- aspose-words-17.11-jdk16)
And we know that document processed via evaluation mode support only 10pages… (source: forum.aspose.com).

This is a best-effort explanation based on partial or unverified information because No retriever returned supporting documents yet and Only low-trust or forum sources were retrieved; please validate it against official documentation once supporting evidence is available.

Checklist / next steps:

  • All pages of Document are not Exported | DOCX to PDF Conversion using Java (forum.aspose.com):

    @tahir.manzoor
    We are using license version of aspose(Aspose word version:- aspose-words-17.11-jdk16)
    And we know that document processed via evaluation mode support only 10pages…

  • /Aspose.WordsforJava.lic (forum.aspose.com): Get Evaluation Note message when generating documents using trial license Dear Support, This is request from Sai Kiran Chebiyyam saikiranchebiyyam@newgensoft.com: As you are aware, we are currently evaluating the 30-day trial version o…
  • /pageNum.doc (forum.aspose.com): Word To Pdf:Page number orientation is incorrect When I convert a Word document to PDF, the page number orientation is incorrect. version:words-25.10-jdk17.jar file: TEST.7z (9.9 M…
  • Version regression lead (question): Behaviour changed between 1 → 2; review release notes or rerun with layout refresh disabled to isolate the change.
  • SpatialReferenceSystem.Wgs84 usage (question): Inspect recent commits or release notes for changes to this API’s defaults or layout behaviour.
  • Share these hypotheses with support engineers alongside logs, code samples, and the exact SDK version so they can confirm the behaviour.
  • Question summary: Sample for validating tests Hi, I want sample code for my unit tests that convert from one format to all other formats include itself. I want the check will: 1. Check the number of layers for input and output file, number of features in layers, number of attributes and geometr…

Not satisfying my questions.
Please help.
Your help is appreciated here.

@danies8

you need to take file which you know what inside and after conversion check it. Something Like this:

string sourcePath = Path.Combine(TestConfiguration.TestDataPath, “file_gdb”, “ThreeLayers.gdb”);
string destinationPath = GetOutputPath(“.json”);
VectorLayer.Convert(sourcePath, Drivers.FileGdb, destinationPath, Drivers.GeoJson);
using (var layer = VectorLayer.Open(destinationPath, Drivers.GeoJson))
{
Assert.AreEqual(15, layer.Count);
// layer1
for (int i = 0; i < 5; ++i)
{
Assert.AreEqual(i, layer[i].GetValue(“Value”));
}
// layer2
for (int i = 5; i < 10; ++i)
{
int localIndex = i - 5;
var multiPoint = new MultiPoint();
for (int j = 0; j < localIndex; ++j)
{
multiPoint.Add(new Point(10, 10));
}
multiPoint.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84;
IGeometry geometry = multiPoint.IsEmpty ? Geometry.Null : multiPoint;
GeometryAssert.AreEqual(geometry, layer[i].Geometry, tolerance: 1e-6);
}
// layer3
for (int i = 10; i < 15; ++i)
{
int localIndex = i - 10;
Assert.AreEqual(localIndex10_000, layer[i].GetValue(“Value1”));
Assert.AreEqual(-localIndex
10_000, layer[i].GetValue(“Value2”));
}
}

Or
you can create new file, set what you need and then check it after conversion. Like this:

var sourcePath = GetRandomPath(“shp”);
var destinationPath = GetRandomPath(“json”);

using (var layer = VectorLayer.Create(sourcePath, Drivers.Shapefile))
{
layer.Attributes.Add(new FeatureAttribute(“string”, AttributeDataType.String));
layer.Attributes.Add(new FeatureAttribute(“double”, AttributeDataType.Double) { Width = 10, Precision = 5 });
layer.Attributes.Add(new FeatureAttribute(“date”, AttributeDataType.Date));

var feature = layer.ConstructFeature();
feature.SetValue("string", "foo");
feature.SetValue("double", 100 / 3.0);
feature.SetValue("date", new DateTime(1999, 4, 2));
layer.Add(feature);

}

VectorLayer.Convert(sourcePath, Drivers.Shapefile, destinationPath, Drivers.GeoJson);

using (var convertedLayer = VectorLayer.Open(destinationPath, Drivers.GeoJson))
{
var feature = convertedLayer[0];
Assert.AreEqual(“foo”, feature.GetValue(“string”));
Assert.AreEqual(33.33333, feature.GetValue(“double”));
Assert.AreEqual(new DateTime(1999, 4, 2), feature.GetValue(“date”));
}

Thank you for replay.
I read your samples code.
You said that I need to know!! the content of input file and accordingly make the comparisons with the target,
By opening the destinations, and make comparisons.
1.No options to make these without knowing the input content?
2.Does each convert from one format to another
Need diffrents tests?
3.Does i need to make this check from one format
To all formats. If i have 15 formsts,need 225 tests?

Hi, @danies8

I’ll be back with an answer in a couple of days.

Hi, @danies8

  1. yes, you can write tests as you wish
  2. no, during conversion you read the file and then write a new file. You said you have some tests, what kind of test you have?
  3. no