Beispiel #1
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);
        }
Beispiel #2
0
        public void FromToken_CreativeCommons_GiveExpectedAttributes()
        {
            CreativeCommonsLicense ccLicense = (CreativeCommonsLicense)LicenseInfo.FromToken("by");

            Assert.That(ccLicense.AttributionRequired, Is.True);
            Assert.That(ccLicense.CommercialUseAllowed, Is.True);
            Assert.That(ccLicense.DerivativeRule, Is.EqualTo(CreativeCommonsLicense.DerivativeRules.Derivatives));


            ccLicense = (CreativeCommonsLicense)LicenseInfo.FromToken("by-sa");
            Assert.That(ccLicense.AttributionRequired, Is.True);
            Assert.That(ccLicense.CommercialUseAllowed, Is.True);
            Assert.That(ccLicense.DerivativeRule, Is.EqualTo(CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike));

            ccLicense = (CreativeCommonsLicense)LicenseInfo.FromToken("by-nd");
            Assert.That(ccLicense.AttributionRequired, Is.True);
            Assert.That(ccLicense.CommercialUseAllowed, Is.True);
            Assert.That(ccLicense.DerivativeRule, Is.EqualTo(CreativeCommonsLicense.DerivativeRules.NoDerivatives));


            ccLicense = (CreativeCommonsLicense)LicenseInfo.FromToken("by-nc");
            Assert.That(ccLicense.AttributionRequired, Is.True);
            Assert.That(ccLicense.CommercialUseAllowed, Is.False);
            Assert.That(ccLicense.DerivativeRule, Is.EqualTo(CreativeCommonsLicense.DerivativeRules.Derivatives));


            ccLicense = (CreativeCommonsLicense)LicenseInfo.FromToken("by-nc-sa");
            Assert.That(ccLicense.AttributionRequired, Is.True);
            Assert.That(ccLicense.CommercialUseAllowed, Is.False);
            Assert.That(ccLicense.DerivativeRule, Is.EqualTo(CreativeCommonsLicense.DerivativeRules.DerivativesWithShareAndShareAlike));

            ccLicense = (CreativeCommonsLicense)LicenseInfo.FromToken("by-nc-nd");
            Assert.That(ccLicense.AttributionRequired, Is.True);
            Assert.That(ccLicense.CommercialUseAllowed, Is.False);
            Assert.That(ccLicense.DerivativeRule, Is.EqualTo(CreativeCommonsLicense.DerivativeRules.NoDerivatives));
        }
Beispiel #3
0
 public void FromToken_Ask_GiveCustomLicense()
 {
     Assert.That(LicenseInfo.FromToken("custom"), Is.InstanceOf <CustomLicense>());
 }
Beispiel #4
0
 public void FromToken_Ask_GiveNullLicense()
 {
     Assert.That(LicenseInfo.FromToken("ask"), Is.InstanceOf <NullLicense>());
 }