Skip to content

Add comprehensive tests for CGImageProperties classes #23041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jun 13, 2025

This PR adds comprehensive test coverage for CGImageProperties classes that were previously missing tests, as requested in issue #17315.

Changes Made

New Test Files Created:

  • CGImagePropertiesExifTest.cs - Tests EXIF metadata properties including aperture, exposure time, flash, pixel dimensions, and various floating-point properties
  • CGImagePropertiesIptcTest.cs - Tests IPTC metadata properties including byline, caption, location, copyright, and credit information
  • CGImagePropertiesJfifTest.cs - Tests JFIF properties including X/Y density values with various edge cases
  • CGImagePropertiesPngTest.cs - Tests PNG-specific properties including author, description, gamma, resolution, and Unicode string handling
  • CGImagePropertiesTiffTest.cs - Tests TIFF properties including orientation, resolution, software information, and Unicode support

Enhanced Existing Test:

  • CGImagePropertiesGPSTest.cs - Added comprehensive tests for GPS properties including constructors, setters, altitude, and edge cases (previously only had one basic test)

Test Coverage Details

Each test file includes:

  • Constructor tests (default and with dictionary)
  • Property get/set functionality
  • Integration with main CGImageProperties class
  • Nullable property handling
  • Edge case testing
  • Unicode string support where applicable
  • Domain-specific tests (GPS coordinates, TIFF orientations, PNG gamma values, etc.)

Example Test Usage

// Test EXIF properties
var exif = new CGImagePropertiesExif();
exif.Aperture = 2.8f;
exif.ExposureTime = 0.125f;
Assert.AreEqual(2.8f, exif.Aperture, 0.001f);

// Test GPS coordinates
var gps = new CGImagePropertiesGps();
gps.Latitude = 37.7749f; // San Francisco
gps.Longitude = -122.4194f;
gps.LatitudeRef = "N";
gps.LongitudeRef = "W";

Test Statistics

  • 49 total test methods across 6 test files
  • 863 lines of comprehensive test code
  • All tests follow existing repository patterns and use NUnit framework

The tests will be automatically included in the build due to existing include patterns in the project files ($(MonoTouchTestDirectory)\**\*.cs).

Fixes #17315.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add More tests for CGImageProperties Add comprehensive tests for CGImageProperties classes Jun 13, 2025
@Copilot Copilot AI requested a review from rolfbjarne June 13, 2025 14:49
Copilot finished work on behalf of rolfbjarne June 13, 2025 14:49
Assert.AreEqual ("Test 測試 Software", tiff.Software, "Software should handle unicode");
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always add a new line at the end of files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit ffed716. Added newlines at the end of all test files.

[Test]
public void ConstructorWithDictionaryTest ()
{
var dict = new NSMutableDictionary ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use using ... for disposable classes. NSMutableDictionary is disposable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit ffed716. Wrapped NSMutableDictionary in using statements for proper disposal in all test files.

public void IntegrationWithCGImagePropertiesTest ()
{
// Test that CGImageProperties can access Exif properties
string file = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use var whenever possible.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit ffed716. Using var for type inference where possible throughout all test files.

{
// Test default constructor
var exif = new CGImagePropertiesExif ();
Assert.IsNotNull (exif, "Default constructor should create a valid instance");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use NUnit v4 syntax (Assert.That ...)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit ffed716. Converted all Assert.AreEqual/IsNotNull/IsNull calls to NUnit v4 syntax using Assert.That with Is.EqualTo/Is.Not.Null/Is.Null across all test files.

Comment on lines 1 to 11
using System;
using Foundation;
#if MONOMAC
using AppKit;
#else
using UIKit;
#endif
using CoreGraphics;
using NUnit.Framework;
using System.IO;
using CoreImage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place usings in three blocks: first System*, then macios frameworks (AppKit, CoreGraphics, UIKit, etc.), finally NUnit*. Also sort the usings in each block alphabetically. Do this for each new file in this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit ffed716. Reorganized using statements in all test files into three blocks: System* (sorted alphabetically), then macios frameworks (CoreGraphics, CoreImage, Foundation, AppKit/UIKit), then NUnit*, all sorted alphabetically within each block.

- Reorganize using statements: System*, then macios frameworks, then NUnit*
- Convert Assert.AreEqual/IsNotNull/IsNull to NUnit v4 syntax (Assert.That)
- Use 'using' statements for NSMutableDictionary (disposable)
- Add newlines at end of all test files
- Use 'var' where appropriate

Addresses feedback from @rolfbjarne in PR review comments.

Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com>
Copilot finished work on behalf of rolfbjarne June 13, 2025 15:11
@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: f4c773ef-daa9-4978-82cb-cd0fbba5605d

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: b83083fd-e97f-45c7-9a45-4b6727cca31e

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 72ac500c-940f-4f37-aef6-801e6701a10b

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 83ac27d6-0c3a-4ea2-a4c8-b9f85cf99b42

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: d2bec16f-e636-439e-9ba2-cbd2fa5979ca

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 267ef4bc-5d66-4d4c-9ed6-fe7e355de1cc

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 6f9a60d6-f7f8-4958-8255-2557fb093fa8

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: feb4ec41-c7b6-4843-b06c-9dd4e0f9ed4d

Sorry for the inconvenience!

[Test]
public void ConstructorWithDictionaryTest ()
{
using (var dict = new NSMutableDictionary ()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the "using" declaration syntax instead of the using block syntax to reduce nesting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 8f80441. Converted all using blocks to using declarations throughout all CGImageProperties test files to reduce nesting.

Co-authored-by: mandel-macaque <2190086+mandel-macaque@users.noreply.github.com>
Copilot finished work on behalf of mandel-macaque June 13, 2025 18:28
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #8f80441] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 8f804416d67a4c6a473c9d91ba70b55bcfb05b08 [PR build]

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 27019c1a-11d6-4870-8ee2-5d4d7e666c56

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #8f80441] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 8f804416d67a4c6a473c9d91ba70b55bcfb05b08 [PR build]

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 7f92df1d-5ade-4d7c-81dc-20d4fc20d1e9

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

✅ API diff vs stable

.NET ( No breaking changes )

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 8f804416d67a4c6a473c9d91ba70b55bcfb05b08 [PR build]

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: c7e7b213-370a-47ce-842a-7ddc7ce09310

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #8f80441] Build failed (Build macOS tests) 🔥

Build failed for the job 'Build macOS tests' (with job status 'Failed')

Pipeline on Agent
Hash: 8f804416d67a4c6a473c9d91ba70b55bcfb05b08 [PR build]

Copy link
Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: efd9125a-d8b0-490a-9912-e571c9b1ea40

Sorry for the inconvenience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add More tests for CGImageProperties
4 participants