public void ChangeVersion_HasChanges_True() { var l = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike); l.HasChanges = false; l.Version = "3.23"; Assert.IsTrue(l.HasChanges); }
public void SetupReasonableLicenseDefaultBeforeEditing() { if (License == null || License is NullLicense) { License = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.Derivatives); } }
public void ChangeCommercialUseAllowed_HasChanges_True() { var l = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike); l.HasChanges = false; l.CommercialUseAllowed = !l.CommercialUseAllowed; Assert.IsTrue(l.HasChanges); }
public void ChangeAttributionRequired_HasChanges_True() { var l = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike); l.HasChanges = false; l.AttributionRequired = !l.AttributionRequired; Assert.IsTrue(l.HasChanges); }
public void RoundTrip_BY_SA() { var original = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike); var copy = CreativeCommonsLicense.FromLicenseUrl(original.Url); Assert.AreEqual(copy.AttributionRequired, true); Assert.AreEqual(copy.CommercialUseAllowed, true); Assert.AreEqual(copy.DerivativeRule, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike); }
public void RoundTrip_BY_NC_ND() { var original = new CreativeCommonsLicense(true, false, CreativeCommonsLicense.DerivativeRules.NoDerivatives); var copy = CreativeCommonsLicense.FromLicenseUrl(original.Url); Assert.AreEqual(copy.AttributionRequired, true); Assert.AreEqual(copy.CommercialUseAllowed, false); Assert.AreEqual(copy.DerivativeRule, CreativeCommonsLicense.DerivativeRules.NoDerivatives); }
/// <summary> /// Create a CCL from a string produced by the Token method of a CCL. /// It will have the current default Version. /// Other values are not guaranteed to work, though at present they will. /// Enhance: Possibly we should try to verify that the token is a valid CCL one? /// </summary> /// <param name="token"></param> /// <returns></returns> public static LicenseInfo FromToken(string token) { var result = new CreativeCommonsLicense(); // Note (JH): Since version was set to default, as I add the qualifier, I'm going to let it be default as well. result.Url = MakeUrlFromParts(token, kDefaultVersion, null); return(result); }
public static CreativeCommonsLicense FromLicenseUrl(string url) { if (url == null || url.Trim() == "") { throw new ArgumentOutOfRangeException(); } var l = new CreativeCommonsLicense(); l.Url = url; return(l); }
public static LicenseInfo FromXmp(Dictionary <string, string> properties) { if (properties.ContainsKey("license") && properties["license"].Contains("creativecommons")) { return(CreativeCommonsLicense.FromMetadata(properties)); } else if (properties.ContainsKey("rights (en)")) { return(CustomLicense.FromMetadata(properties)); } return(new NullLicense()); }
//Review (JH asks in Oct 2016): Why does this exist? The only uses in libpalaso are in tests and examples. Bloom does not use it. // Why is From Url not sufficient? public static LicenseInfo FromToken(string abbr) { switch (abbr) { case "ask": return(new NullLicense()); case "custom": return(new CustomLicense()); default: return(CreativeCommonsLicense.FromToken(abbr)); } }
public void TypicalEmbedInJson() { // example var license = new CreativeCommonsLicense(true, false, CreativeCommonsLicense.DerivativeRules.Derivatives); license.RightsStatement = "Please acknowledge using 'Based on work of SIL International'"; var json = "{\"license\":'" + license.Token + "\",\"rights\":\"" + license.RightsStatement + "\"}"; // store json somewhere. // parse json and get var token = "custom"; // from license field var rights = "Academic Institutions may use this free of charge"; // reconstitute the license var recoveredLicense = LicenseInfo.FromToken(token); license.RightsStatement = rights; Assert.That(recoveredLicense, Is.InstanceOf<CustomLicense>()); Assert.That(LicenseInfo.FromToken("ask"), Is.InstanceOf<NullLicense>()); var ccLicense = LicenseInfo.FromToken("by-nc-sa"); Assert.That(ccLicense, Is.InstanceOf<CreativeCommonsLicense>()); Assert.That(((CreativeCommonsLicense)ccLicense).AttributionRequired, Is.True); }
public static CreativeCommonsLicense FromLicenseUrl(string url) { if(url==null || url.Trim()=="") { throw new ArgumentOutOfRangeException(); } var l = new CreativeCommonsLicense(); l.Url = url; return l; }
/// <summary> /// Create a CCL from a string produced by the Token method of a CCL. /// It will have the current default Version. /// Other values are not guaranteed to work, though at present they will. /// Enhance: Possibly we should try to verify that the token is a valid CCL one? /// </summary> /// <param name="token"></param> /// <returns></returns> public static LicenseInfo FromToken(string token) { var result = new CreativeCommonsLicense(); result.Url = MakeUrlFromTokenAndVersion(token, kDefaultVersion); return result; }
public void HasChanges_CanToggle() { var l = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike); l.HasChanges = false; Assert.IsFalse(l.HasChanges); l.HasChanges = true; Assert.IsTrue(l.HasChanges); }
public void GetDescription_NoTranslation_GivesEnglish() { var l = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike); string languageUsed; Assert.AreEqual(l.GetDescription(new[] { "en" }, out languageUsed), l.GetDescription(new[]{"qx", "en"}, out languageUsed)); Assert.AreEqual("en",languageUsed); }
public void SetupReasonableLicenseDefaultBeforeEditing() { if(License == null || License is NullLicense) { License= new CreativeCommonsLicense(true,true,CreativeCommonsLicense.DerivativeRules.Derivatives); } }
public void ChangeDerivativeRule_HasChanges_True() { var l = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike); l.HasChanges = false; l.DerivativeRule = CreativeCommonsLicense.DerivativeRules.NoDerivatives; Assert.IsTrue(l.HasChanges); }
public void Url_GivesVersion() { var original = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.Derivatives); original.Version = "2.2"; Assert.AreEqual("http://creativecommons.org/licenses/by/2.2/", original.Url); }
/// <summary> /// Create a CCL from a string produced by the Token method of a CCL. /// It will have the current default Version. /// Other values are not guaranteed to work, though at present they will. /// Enhance: Possibly we should try to verify that the token is a valid CCL one? /// </summary> /// <param name="token"></param> /// <returns></returns> public static LicenseInfo FromToken(string token) { var result = new CreativeCommonsLicense(); // Note (JH): Since version was set to default, as I add the qualifier, I'm going to let it be default as well. result.Url = MakeUrlFromParts(token, kDefaultVersion, null); return result; }