385 Commits

Author SHA1 Message Date
Sergio Pedri f8b7609e9e Parameterize tests for multiple C# language versions
Update unit tests to run against different C# language versions: add DataRow(LanguageVersion.Preview) to each test and, under ROSLYN_5_0_0_OR_GREATER, add DataRow(LanguageVersion.CSharp14). Change test methods to accept a LanguageVersion parameter and use it when constructing CSharpCodeFixTest (replace hardcoded LanguageVersion.Preview). Conditional compilation preserves compatibility with older Roslyn targets.
2026-03-16 17:37:02 -07:00
Sergio Pedri 4222078b2d Add analyzer tests for C# 14 language version
Introduces new unit tests under the ROSLYN_5_0_0_OR_GREATER conditional to verify analyzer diagnostics and code generation behavior when using C# 14. These tests ensure correct warnings are produced for observable properties and WinRT compatibility in this language version.
2026-01-27 16:23:21 -08:00
Sergio Pedri 2a86742667 Update package dependencies to latest versions
Bump Microsoft.Bcl.AsyncInterfaces, System.Text.Json, and System.Formats.Asn1 to version 10.0.1 in main and test projects to address security and compatibility improvements.
2026-01-12 13:33:27 -08:00
Youssef Victor e635084535 More tests for semi auto prop analyzer 2025-11-24 15:39:18 -08:00
Marcin Krystianc 8323145328 Eliminate this = default shortcut when height * width = 0 2025-11-24 14:52:57 -08:00
Sergio Pedri 27d43c1188 Update C# language version to 14.0 in test project
Changed the LangVersion property from 'preview' to '14.0' in the CommunityToolkit.Mvvm.Roslyn5000.UnitTests.csproj file to explicitly target C# 14.0 for test builds.
2025-11-24 14:30:28 -08:00
Sergio Pedri ab4e3c21ac Remove Roslyn 5.0.0 workaround and update test dependency
Eliminated the temporary workaround for Roslyn 5.0.0 in the props file and updated the test project's Microsoft.CodeAnalysis.CSharp.Workspaces package reference from 5.0.0-2.final to 5.0.0. This aligns the configuration with the stable Roslyn release.
2025-11-24 14:28:58 -08:00
Sergio Pedri ea014da0fe Add C# 14 partial property tests and fix formatting
Introduces new unit tests for ObservableProperty with value types on partial properties using C# 14 and Roslyn 5.0.0 or greater. Also updates formatting in diagnostics tests for consistency and readability.
2025-11-24 14:28:58 -08:00
Sergio Pedri dffc56d7ee Add Roslyn5000 unit test project and fix project reference
Added CommunityToolkit.Mvvm.SourceGenerators.Roslyn5000.UnitTests project to the solution and corrected the project reference in CommunityToolkit.Mvvm.csproj to point to the correct Roslyn5000 source generator. This enables testing for Roslyn 5.0.0 support.
2025-11-24 14:28:58 -08:00
Sergio Pedri 3d97ed279f Add Roslyn 5.0.0 unit test project
Introduces CommunityToolkit.Mvvm.Roslyn5000.UnitTests.csproj targeting net472, net8.0, and net9.0. Updates the solution file to include the new test project for Roslyn 5.0.0 compatibility testing.
2025-11-24 14:28:58 -08:00
Sergio Pedri 272a9749a7 Update analyzer for C# 14.0 language version support
Renamed RequiresCSharpLanguageVersionPreviewAnalyzer to RequiresCSharpLanguageVersion14OrPreviewAnalyzer and updated logic to check for C# 14.0 or preview language versions. Adjusted generator and unit tests to reference the new analyzer and updated version checks for compatibility with Roslyn 5.0.0 or greater.
2025-11-24 14:28:58 -08:00
Sergio Pedri 796d8d0956 Add .NET 10.0 target to all unit test projects
Updated the TargetFrameworks property in all unit test .csproj files to include net10.0, enabling tests to run against the latest .NET version.
2025-11-24 13:54:41 -08:00
Sergio Pedri 5f2f8174fb Update NuGet packages to latest stable 2025-11-10 12:20:12 -08:00
Sergio Pedri 85d26bf421 Update NuGet packages to latest stable 2025-11-10 12:17:43 -08:00
Sergio Pedri e5ada2ebf1 Fix warning for 'Asn1' package 2025-11-10 12:16:28 -08:00
Sergio Pedri 013b10cd71 Update NuGet packages to latest stable 2025-11-10 11:56:58 -08:00
Sergio Pedri 9be2ae6ee7 Update NuGet packages to latest stable 2025-11-10 11:55:49 -08:00
Sergio Pedri 1abeff602b Mark more members as 'readonly' 2025-11-10 11:54:56 -08:00
Sergio Pedri 6e83642f07 Enable parallel test execution via shared target
Moved the ParallelizeAttribute configuration from individual test project files to the shared Community.Toolkit.Common.targets file. This centralizes the configuration and ensures all test projects run tests in parallel by default.
2025-11-09 18:48:08 -08:00
Sergio Pedri d2ceba9b14 Enable parallel test execution in MSTest projects
Added the Microsoft.VisualStudio.TestTools.UnitTesting.ParallelizeAttribute to all MSTest-based unit test project files to enable parallel test execution. This change should improve test run performance by allowing tests to run concurrently.
2025-11-09 18:46:37 -08:00
Sergio Pedri 8ef70099d8 Refactor assertion in ObservableValidator test
Replaces Assert.IsTrue(!...) with Assert.IsFalse(...) for clarity in the Test_ObservableValidator_ValidateReturn test.
2025-11-09 18:41:43 -08:00
Sergio Pedri c75df26eea Assign Assert results to discard in unit test
Updated assertions in Test_RelayCommandAttribute_WithPartialCommandMethodDefinitions to assign results to the discard variable, improving code clarity and suppressing possible warnings about unused return values.
2025-11-09 18:37:55 -08:00
Sergio Pedri 4cc23d4568 Replace Assert.AreEqual with Assert.HasCount in tests
Updated unit tests in Test_ObservableValidator.cs to use Assert.HasCount instead of Assert.AreEqual for collection count assertions. This improves clarity and consistency in test assertions.
2025-11-09 18:37:22 -08:00
Sergio Pedri d8d3d07c88 Cast stream.Position to int in Assert.HasCount calls
Updated all usages of Assert.HasCount to explicitly cast stream.Position to int. This ensures type consistency and prevents potential issues when stream.Position is a long.
2025-11-09 18:36:55 -08:00
Sergio Pedri 12ae36b594 Refactor unit tests to use new assertion helpers
Replaces usages of Assert.AreEqual, Assert.IsTrue, and similar assertions with new helper methods such as Assert.HasCount, Assert.IsEmpty, Assert.IsNull, and Assert.IsGreaterThanOrEqualTo across multiple test files. This improves test readability and consistency with updated assertion APIs.
2025-11-09 18:34:09 -08:00
Sergio Pedri e88c524c3e Refactor unit tests to use expected-first Assert.AreEqual
Updated all unit tests to consistently use the expected value as the first argument in Assert.AreEqual calls. This improves readability and aligns with best practices for test assertions.
2025-11-09 18:33:21 -08:00
Sergio Pedri 2cf609c877 Update MSTest packages to version 4.0.1 in test projects
Upgraded MSTest.TestAdapter and MSTest.TestFramework from version 3.11.0 to 4.0.1 across all unit test project files to ensure compatibility with the latest features and bug fixes.
2025-11-09 18:30:20 -08:00
Sergio Pedri 417ae60969 Remove duplicate DataRow attributes in unit tests
Eliminated repeated [DataRow(64, 4, 0)] attributes from three test methods in Test_MemoryExtensions.cs to avoid redundant test cases and improve test clarity.
2025-11-07 14:56:47 -08:00
Sergio Pedri 5eb6a68b42 Don't use '[ExpectedException]' in HighPerformance tests 2025-11-07 14:56:47 -08:00
Sergio Pedri 0892002d0c Don't use '[ExpectedException]' in Diagnostics tests 2025-11-07 13:22:54 -08:00
Sergio Pedri c1555a7e5d Don't use '[ExpectedException]' in MVVM tests 2025-11-07 13:22:54 -08:00
Sergio Pedri 2b42d139af Use Assert.ThrowsExactly in unit tests
Replaces usage of Assert.ThrowsException with Assert.ThrowsExactly across multiple unit test files to ensure that tests only pass when the exact exception type is thrown, improving test precision and reliability.
2025-11-07 11:56:48 -08:00
Sergio Pedri 5215c84a7f Update MSTest packages to version 3.11.0 in test projects
Upgrades MSTest.TestAdapter and MSTest.TestFramework from 3.6.4 to 3.11.0 across all unit test project files to ensure compatibility with latest features and bug fixes.
2025-11-06 16:10:55 -08:00
Sergio Pedri 7d4d6ec84b Handle 'CanExecute' with method overrides 2025-11-06 10:33:29 -08:00
Sergio Pedri 77e0435df0 Bump unit tests from .NET 7 to .NET 9 2025-11-05 12:55:43 -08:00
Sergio Pedri 3c720ddf7b Handle semi-auto properties with expression bodies 2024-12-11 22:33:27 -08:00
Sergio Pedri 6cf850fe38 Improve filtering in semi-auto property analyzer 2024-12-11 16:17:08 -08:00
Sergio Pedri a91e7a8b48 Handle adding using directives if needed 2024-12-10 20:13:46 -08:00
Sergio Pedri df714eaa6c Add support for 'get;' accessors too 2024-12-10 20:13:46 -08:00
Sergio Pedri da8901493f Fix leading trivia in accessors, add tests 2024-12-10 20:13:46 -08:00
Sergio Pedri e3489068a9 Only remove leading trivia, add tests 2024-12-10 20:13:46 -08:00
Sergio Pedri 5e3d65fede Improve handling of attribute lists, fix tests 2024-12-10 20:13:46 -08:00
Sergio Pedri 46cd488bdf Add more unit tests for code fixer 2024-12-10 20:13:46 -08:00
Sergio Pedri 450fb9f9c5 Add unit test for code fixer 2024-12-10 20:13:46 -08:00
Sergio Pedri 7c6eeb6f7f Add unit tests for new analyzer 2024-12-10 20:13:46 -08:00
Youssef Victor 78348ca09a Improve test coverage for SpanExtensions.IndexOf (#1023) 2024-12-10 19:47:24 -08:00
Sergio Pedri 1bfc5a498b Add unit tests for inheritance scenarios 2024-12-06 19:41:11 -08:00
Sergio Pedri fb0facdc98 Add unit tests for new scenarios 2024-12-06 19:35:48 -08:00
Sergio Pedri a8aaeb57e9 Update NuGet packages to latest stable 2024-12-05 09:27:31 -08:00
Sergio Pedri 00fdbef4df Add unit tests for analyzer changes 2024-12-05 08:59:47 -08:00