Esempio n. 1
0
        /// <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 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 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 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 ChangeAttributionRequired_HasChanges_True()
		{
			var l = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike);
			l.HasChanges = false;
			l.AttributionRequired = !l.AttributionRequired;
			Assert.IsTrue(l.HasChanges);
		}
Esempio n. 6
0
 public void SetupReasonableLicenseDefaultBeforeEditing()
 {
     if (License == null || License is NullLicense)
     {
         License = new CreativeCommonsLicense(true, true, CreativeCommonsLicense.DerivativeRules.Derivatives);
     }
 }
		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);
		}
 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);
 }
Esempio n. 10
0
        public static CreativeCommonsLicense FromLicenseUrl(string url)
        {
            if (url == null || url.Trim() == "")
            {
                throw new ArgumentOutOfRangeException();
            }
            var l = new CreativeCommonsLicense();

            l.Url = url;
            return(l);
        }
Esempio n. 11
0
        public static LicenseInfo FromToken(string abbr)
        {
            switch (abbr)
            {
            case "ask": return(new NullLicense());

            case "custom": return(new CustomLicense());

            default:
                return(CreativeCommonsLicense.FromToken(abbr));
            }
        }
Esempio n. 12
0
 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());
 }
Esempio n. 13
0
		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 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);
		}
Esempio n. 15
0
 public void SetupReasonableLicenseDefaultBeforeEditing()
 {
     if(License == null || License is NullLicense)
     {
         License= new CreativeCommonsLicense(true,true,CreativeCommonsLicense.DerivativeRules.Derivatives);
     }
 }
 /// <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 static CreativeCommonsLicense FromLicenseUrl(string url)
 {
     if(url==null || url.Trim()=="")
     {
         throw new ArgumentOutOfRangeException();
     }
     var l = new CreativeCommonsLicense();
     l.Url = url;
     return l;
 }
		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);
		}