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 11 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@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.

@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
Contributor 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
Contributor 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.

{
// 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
Contributor 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
Contributor 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 <[email protected]>
Copilot finished work on behalf of rolfbjarne June 13, 2025 15:11
@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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.

Copy link
Contributor Author

Copilot AI commented Jul 7, 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: 5ef0ca57-83d3-4f25-97e7-12c816fb1b70

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Contributor Author

Copilot AI commented Jul 7, 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: 7f7d529a-b881-4d6c-902f-c3bf8fe86120

Sorry for the inconvenience!

@rolfbjarne
Copy link
Member

@copilot revert the last commit

Copy link
Contributor Author

Copilot AI commented Jul 10, 2025

@copilot revert the last commit

Reverted the last commit (7f13dbb) as requested. HEAD is now at commit 2d591b0.

Copilot finished work on behalf of rolfbjarne July 10, 2025 10:40
@rolfbjarne
Copy link
Member

@copilot undo the last commit

Copy link
Contributor Author

Copilot AI commented Jul 10, 2025

@copilot undo the last commit

Undone in commit 37233ec. Reverted the changes back to using declarations in all CGImageProperties test files.

Copilot finished work on behalf of rolfbjarne July 10, 2025 11:15
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #37233ec] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 37233ecb3762e26525d224df4337e21aa03959cb [PR build]

Copy link
Contributor Author

Copilot AI commented Jul 10, 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: b55f5c57-9821-4058-bca4-a5e0070ec96a

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 Failed to compare API and create generator diff 🔥

** Error: Working directory isn't clean - check build log for more information.

Pipeline on Agent
Hash: 37233ecb3762e26525d224df4337e21aa03959cb [PR build]

Copy link
Contributor Author

Copilot AI commented Jul 10, 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: 18c2c930-a4c1-41f4-a950-aa932c0a4579

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #37233ec] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 37233ecb3762e26525d224df4337e21aa03959cb [PR build]

Copy link
Contributor Author

Copilot AI commented Jul 10, 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: a95bb047-5c81-45fe-a283-ed9c9ba42baa

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #37233ec] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 37233ecb3762e26525d224df4337e21aa03959cb [PR build]

Copy link
Contributor Author

Copilot AI commented Jul 10, 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: 6fc11d8a-5f24-41c4-97b0-a39c6aecfa09

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #37233ec] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 37233ecb3762e26525d224df4337e21aa03959cb [PR build]

Copy link
Contributor Author

Copilot AI commented Jul 10, 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: 2c4d1a34-8da1-434c-8e98-6002c69a27bb

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #37233ec] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 37233ecb3762e26525d224df4337e21aa03959cb [PR build]

Copy link
Contributor Author

Copilot AI commented Jul 10, 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: 657787cb-747c-4fb4-873b-fb4dfe3ce43b

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #37233ec] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 37233ecb3762e26525d224df4337e21aa03959cb [PR build]

Copy link
Contributor Author

Copilot AI commented Jul 10, 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: 096c153e-6dc5-4570-ac1d-c9a07fed5560

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #37233ec] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 37233ecb3762e26525d224df4337e21aa03959cb [PR build]

Copy link
Contributor Author

Copilot AI commented Jul 10, 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: 5aa4f47a-3a55-4666-a7b3-cb20952f7128

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #37233ec] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 117 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 37233ecb3762e26525d224df4337e21aa03959cb [PR build]

Copy link
Contributor Author

Copilot AI commented Jul 10, 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: 09a3489f-382a-4cf0-93db-ecc4fbcccc5a

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