Open MikeWilliams-UK opened 1 year ago
If anyone comes across this, the correct way to implement this can be found in @junian's tests projects for Standard.Licensing.
Example:
var validationFailures = license.Validate()
.ExpirationDate(systemDateTime: DateTime.Now)
.When(lic => lic.Type == LicenseType.Trial)
.And()
.Signature(EncryptedPublicKey)
.And()
.AssertThat(lic => lic.ProductFeatures.Contains("Sales Module"), new GeneralValidationFailure { Message = "Sales Module not licensed!" })
.AssertValidLicense();
You can change Sales Module
into anything you want, and it'll trigger the corresponding failure if it's not present in the license.
In a .Net Framework (4.6.2) application.
If you have a licence which has been generated with an attribue of "Random1" and when you validate it you try to get an attribute of "Random2" you get a System.NullReferenceException when using .AssertThat(lic => lic.AdditionalAttributes.Get("Random2")
Same happens if you specify a feature which does not exist in the licence.
I would expect both of these to gracefully fail validation with a message similar to "Attribute 'Random2' not present in the licence."