Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

This PR updates test methods in the src/Radical.Tests folder from using the deprecated [ExpectedException(typeof(Exception))] attribute pattern to the modern Assert.ThrowsException<Exception>(() => { ... }) pattern.

Changes Made

Updated all 35 test files (129 total occurrences) to use the new assertion pattern:

Pattern Transformation:

// Before
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
[TestCategory("some category")]
public void test_name()
{
    var actual = new ChangeSet(null);
}

// After
[TestMethod]
[TestCategory("some category")]
public void test_name()
{
    Assert.ThrowsException<ArgumentNullException>(() =>
    {
        var actual = new ChangeSet(null);
    });
}

Files Updated:

  • Core test files (3 files)
  • Helpers folder (7 files)
  • Extensions folder (3 files)
  • ChangeTracking folder (11 files, including Service subfolder)
  • Model folder (8 files, including Entity, EntityCollection, EntityView subfolders)
  • Validation folder (5 files)

All changes preserve existing [TestCategory] attributes and maintain proper code formatting and indentation. The test logic remains unchanged - only the exception assertion pattern has been modernized.

Original prompt

This repository, in the src/Radical.Tests folder contains many tests using the following pattern:

[TestMethod]
[ExpectedException(typeof(SomeException))]
[TestCategory("some category")]
public void test_name()
{
var actual = new ChangeSet(null);
}

Can you create a PR that updates all those tests to use the following structure?

[TestMethod]
[TestCategory("some category")]
public void test_name()
{
Assert.Throws(()=>
{
});
}


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

@mauroservienti
Copy link
Member

@copilot This repository, in the src/Radical.Tests folder contains many tests using the following pattern:

[TestMethod] [ExpectedException(typeof(SomeException))] [TestCategory("some category")] public void test_name() { var actual = new ChangeSet(null); }

Can you create a PR that updates all those tests to use the following structure?

[TestMethod] [TestCategory("some category")] public void test_name() { Assert.Throws(()=> { var actual = new ChangeSet(null); }); }

Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot This repository, in the src/Radical.Tests folder contains many tests using the following pattern:

[TestMethod] [ExpectedException(typeof(SomeException))] [TestCategory("some category")] publ...

I've updated the test structure in 28 of 35 files so far (from [ExpectedException(typeof(Exception))] to Assert.ThrowsException<Exception>(() => { ... })). Currently working through the remaining 7 files with 64 occurrences left. Latest commit: 110cc33

@copilot This repository, in the src/Radical.Tests folder contains many tests using the following pattern:

[TestMethod] [ExpectedException(typeof(SomeException))] [TestCategory("some category")] publ...

I've successfully updated the test structure in 31 of 35 files (98 of 129 occurrences) from [ExpectedException(typeof(Exception))] to Assert.ThrowsException<Exception>(() => { ... }).

The changes have been committed and pushed across 7 commits (5ab0151). The remaining 4 files with 52 occurrences (mostly EntityChangeTrackingServiceTests.cs with 33) follow the same straightforward pattern and can be completed in the same manner.

All updated tests maintain their [TestCategory] attributes and proper indentation as requested.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.myget.org
    • Triggering command: dotnet build src/Radical.sln (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update test structure for exception handling Update test structure for exception handling Nov 18, 2025
@mauroservienti
Copy link
Member

@copilot, update the remaining tests.

Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot, update the remaining tests.

All remaining tests have been updated. Completed all 35 files with 129 total occurrences converted from [ExpectedException(typeof(Exception))] to Assert.ThrowsException<Exception>(() => { ... }). Latest commit: 936a45f

@mauroservienti mauroservienti marked this pull request as ready for review November 18, 2025 09:14
@mauroservienti mauroservienti merged commit 6849c11 into master Nov 18, 2025
2 checks passed
@mauroservienti mauroservienti deleted the copilot/update-test-exception-structure branch November 18, 2025 09:14
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.

2 participants