.NET on AWS Blog
Port .NET Framework workloads to Linux with Amazon Q Developer, Part 2: Test Projects
Introduction
This blog series explores how to port different kinds of .NET Framework projects to cross-platform .NET with Amazon Q Developer .NET transformation, currently in public preview. Modernizing a Windows-based .NET Framework solution to run on Linux can reduce operational costs by up to 40%. Part 1 covered porting of class library projects. Here in Part 2, I’ll cover test projects.
If you’ve ever participated in the technical overhaul of an existing business application, you can appreciate the importance of being able to confirm that its original functionality and behaviors are still intact. This is doubly important if the original developers are no longer on staff. In the .NET world, test projects can be used to provide that peace of mind. With a comprehensive suite of tests in place, that have good code coverage, you can port your solution and then run your tests afterward to validate the application has not been compromised.
.NET has had test projects since 2012. The most popular test frameworks for them are NUnit, XUnit, and Microsoft Testing Framework (MSTest). Amazon Q Developer .NET transformation can port test projects in all three frameworks. Follow the walkthrough to port a solution with a test project.
Prerequisites
For this tutorial, you will need:
1. Visual Studio 2022 IDE installed.
2. A subscription to Amazon Q Developer Pro.
3. AWS Toolkit for Visual Studio IDE extension installed and configured for Amazon Q Developer.
4. Download or clone the sample application from GitHub.
Walkthrough
The sample application for this walkthrough is MathML, a public GitHub project archive with an MIT license. MathML is a C# library for reading, writing, and editing MathML, a markup language for describing mathematical notation. The solution contains two .NET Framework 4.5.2 projects: the library itself, which is a class library project, and a test project that uses XUnit.
Step 1: Run tests on original solution
In this step, you’ll run the test project against the original solution to confirm its original state.
1. Open the downloaded solution code in Visual Studio.
2. Visual Studio 2022 will prompt you to upgrade the solution projects to .NET Framework 4.8. Accept the upgrade.
3. In Solution Explorer, take a moment to view the two projects in the solution. View the properties of the MathML and MathML.Tests projects to confirm they are .NET Framework 4.8 projects.
4. Open the Test Explorer window, either from the View menu or using keyboard shortcut Ctrl+E, T. Select the top test level, MathML.Tests (59), and click the Run (▶) toolbar button. After a few seconds, you should see the passing test results shown in Figure 1. All 59 tests pass.

Figure 1: All tests pass on original solution
You can expand the levels in Text Explorer to view the code for any of the tests.
Step 2: Port Project with Amazon Q Developer
In this step, you’ll port the solution from .NET Framework to cross-platform .NET with Amazon Q Developer.
1. Connect to Amazon Q. In Visual Studio navigate to Extensions > AWS Toolkit > Getting Started to view the Getting Started: AWS Toolkit with Amazon Q page. Under Amazon Q, if it does not say Connected, click Sign in and sign in with your credentials.
2. Open a code file (any .cs file) in the editor. A code file needs to be open in order for .NET transformation to be enabled.
3. Start porting. In Solution Explorer, right-click the solution and choose Port solution with Amazon Q Developer.
4. On the Port a solution with Amazon Q dialog, choose Start.
5. Soon, a transformation job kicks off, indicated by a notification message at top, Q Transformation is in progress. A transformation plan is displayed similar to Figure 2. Scroll down and expand the table of projects. Both the MathML and MathML.Tests projects will be ported.

Figure 2: Code Transformation Plan
6. Wait for the transformation job to complete (Figure 3). You’ll see a Your transformation is completed notification near the top of Visual Studio when the job completes.

Figure 3: Transformation job complete
Step 3: Review and apply the code transformation
In this step, you’ll review Amazon Q Developer’s proposed changes and apply them to your project.
1. Click the View code transformation summary link to see a summary of changes (Figure 4). You can see that many APIs were changed, but only a few files in each project.

Figure 4: Code Transformation Summary
2. In the Amazon Q Developer Code Transformation Hub pane, click View diffs and view the changes made to each file. In the MathML.csproj and MathML.Tests.csproj project files, the target framework was changed (Figure 5), as well as the files to compile (Figure 6).

Figure 5: Project file changes

Figure 6: Project file changes, continued
3. In the Diffs view, choose Select All and then Apply changes. The code changes have now been applied to your code.
4. In Solution Explorer, view the properties of both projects to confirm they now target .NET 8.
Step 4: Run tests on ported solution
In this step, you’ll run the test project against the ported solution to confirm tests still pass.
1. Build the solution, and you may see a build error NU1605 Warning as Error: Detected package downgrade of xunit.extensibility.cor from 2.9.2 to 2.9.1 Reference the package directly from the project to select a different version. If you receive this error, navigate to Manage NuGet Packages for Solution. On the Updates tab, apply the recommended updates to XUnit packages as shown in Figure 7. The solution should now build without errors.

Figure 7: Update XUnit packages
2. Open the Test Explorer window. Select the top test level, MathML.Tests(59), and click the Run (▶) toolbar button. After a few seconds, you should see the passing test results shown in Figure 8. All 59 tests should pass. This confirms the functionality covered by the tests has not been compromised by the transformation.

Figure 8: All tests pass on ported solution
Conclusion
In this post, you learned how to modernize a .NET Framework solution that includes a test project using Amazon Q Developer .NET transformation. You can safeguard application functionality in a transformation by leveraging test projects. I encourage you to explore modernization of your .NET workloads to AWS during the public preview of .NET transformation. Refer to the Amazon Q Developer User Guide to get started with .NET transformation.