public void CanReadValidLicense() { IsValidIfLocalLicenseDoesNotAlreadyExist(); // Assuming test environment can write in one of folders license file may be. using (var path = new TemporaryFile(LicenseManager.GetLicenseFilePath())) { // In test environment there isn't license file/storage then this test must fail. // After this we must discard cached (and empty) license to load the newly created one. Assert.IsNull(LicenseManager.License); Assert.IsFalse(LicenseManager.IsLicenseValid); LicenseManager.Renew(); // Now we prepare a fake license file to check few basics in // LicenseManager class. var contact = ContactFactory.Create <Contact>(); var license = LicenseFactory.Create <License>(contact); license.Features.Add((int)Feature.Example1, 1); LicenseWriter.ToFile(path, license); Assert.IsTrue(LicenseManager.IsLicenseValid); Assert.IsNotNull(LicenseManager.License); Assert.AreEqual(LicenseManager.License.Id, license.Id); Assert.IsTrue(LicenseManager.IsFeatureAvailable(Feature.Example1)); } }
private static License SaveAndReloadFromDisk(License license) { using (var path = new TemporaryFile()) { LicenseWriter.ToFile(path, license); return(LicenseReader.FromFile(path)); } }
public void ValidForMinorHardwareChanges() { using (var temp = new TemporaryFile()) { var contact = ContactFactory.Create <ContactForSlightlyChangedHardware>(); var license = LicenseFactory.Create <License>(contact); LicenseWriter.ToFile(temp, license); license = LicenseReader.FromFile <LicenseWithSlightlyChangedHardware, IniLicenseTextConverter <LicenseWithSlightlyChangedHardware> >(temp); Assert.IsTrue(license.IsValid()); } }
public void InvalidIfHardwareConfigurationChanged() { using (var temp = new TemporaryFile()) { var contact = ContactFactory.Create <Contact>(); var license = LicenseFactory.Create <License>(contact); LicenseWriter.ToFile(temp, license); license = LicenseReader.FromFile <LicenseWithChangedHardware, IniLicenseTextConverter <LicenseWithChangedHardware> >(temp); Assert.IsFalse(license.IsValid()); } }
public void SelfIssuedLicense() { using (var temp = new TemporaryFile()) { var contact = ContactFactory.Create <Contact>(); var license = LicenseFactory.Create <License>(contact); LicenseWriter.ToFile(temp, license); license = LicenseReader.FromFile(temp); Assert.IsTrue(license.IsValid()); } }