diff --git a/wpf/Licensing/licensing-faq/CI-license-validation.md b/wpf/Licensing/licensing-faq/CI-license-validation.md index c581b7894..5826dd368 100644 --- a/wpf/Licensing/licensing-faq/CI-license-validation.md +++ b/wpf/Licensing/licensing-faq/CI-license-validation.md @@ -147,3 +147,48 @@ bool isValid = SyncfusionLicenseProvider.ValidateLicense(Platform.WPF); * If the ValidateLicense() method returns false, there will be invalid license errors in deployment due to either an invalid license key or an incorrect assembly or package version that is referenced in the project. Please ensure that all the referenced Syncfusion assemblies or NuGet packages are all on the same version as the license key’s version before deployment. +## Validate the License Key By Using the Unit Test Project + +* To create a unit test project in Visual Studio, choose **File -> New -> Project** from the menu. This opens a new dialog for creating a new project. Filtering the project type by Test or typing Test as a keyword in the search option can help you to find available unit test projects. Select the appropriate test framework (such as MSTest, NUnit, or xUnit) that best suits your need. + +![Unit Test Projects](licensing-images/unit-test-projects.png) + +* For more details on creating unit test projects in Visual Studio, refer to the [Getting Started with Unit Testing guide](https://learn.microsoft.com/en-us/visualstudio/test/getting-started-with-unit-testing?view=vs-2022&tabs=dotnet%2Cmstest#create-unit-tests). + +* Register the license key by calling the RegisterLicense("Your License Key") method with the license key in the unit test project. + +N> * Place the license key between double quotes. Also, ensure that Syncfusion.Licensing.dll is referenced in your project where the license key is being registered. + +* Once the license key is registered, it can be validated by using the ValidateLicense("Platform.WPF", out var validationMessage) method. This ensures that the license key is valid for the platform and version you are using. + +* For reference, please check the following example that demonstrates how to register and validate the license key in the unit test project. + +{% tabs %} +{% highlight c# %} +public void TestSyncfusionWPFLicense() +{ + var platform = Platform.WPF; + // Register the Syncfusion license key + SyncfusionLicenseProvider.RegisterLicense("Your License Key"); + + bool isValidLicense = SyncfusionLicenseProvider.ValidateLicense(platform, out var validationMessage); + Assert.That(isValidLicense, Is.True, $"Validation failed for {platform}." + $" Validation Message: {validationMessage}"); + + // Log validation messages to TestContext output + if (isValidLicense) + { + TestContext.Out.WriteLine($"Platform {platform} is correctly licensed for version " + $"{typeof(SyncfusionLicenseProvider).Assembly.GetName().Version}"); + } +} +{% endhighlight %} +{% endtabs %} + +* Once the unit test is executed, if the license key validation passes for the specified platform, the output similar to the following will be displayed in the Test Explorer window. + +![License Validation Success Message](licensing-images/unit-test-success-message.png) + +* If the license validation fails during unit testing, the following output will be displayed in the Test Explorer window. + +![License Validation Failure Message](licensing-images/unit-test-failure-message.png) + +* License validation fails due to either an invalid license key or an incorrect assembly or package version that is referenced in the project. In such cases, verify that you are using the valid license key for the platform, and ensure the assembly or package versions referenced in the project match the version of the license key. \ No newline at end of file diff --git a/wpf/Licensing/licensing-faq/licensing-images/unit-test-failure-message.png b/wpf/Licensing/licensing-faq/licensing-images/unit-test-failure-message.png new file mode 100644 index 000000000..96033da45 Binary files /dev/null and b/wpf/Licensing/licensing-faq/licensing-images/unit-test-failure-message.png differ diff --git a/wpf/Licensing/licensing-faq/licensing-images/unit-test-projects.png b/wpf/Licensing/licensing-faq/licensing-images/unit-test-projects.png new file mode 100644 index 000000000..98d02dfcc Binary files /dev/null and b/wpf/Licensing/licensing-faq/licensing-images/unit-test-projects.png differ diff --git a/wpf/Licensing/licensing-faq/licensing-images/unit-test-success-message.png b/wpf/Licensing/licensing-faq/licensing-images/unit-test-success-message.png new file mode 100644 index 000000000..291bb7060 Binary files /dev/null and b/wpf/Licensing/licensing-faq/licensing-images/unit-test-success-message.png differ