コード例 #1
0
ファイル: ClearShareUsage.cs プロジェクト: vkarthim/libpalaso
        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);
        }
コード例 #2
0
ファイル: LicenseTests.cs プロジェクト: smitcham/libpalaso
        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));
        }
コード例 #3
0
ファイル: LicenseTests.cs プロジェクト: smitcham/libpalaso
 public void FromToken_Ask_GiveCustomLicense()
 {
     Assert.That(LicenseInfo.FromToken("custom"), Is.InstanceOf <CustomLicense>());
 }
コード例 #4
0
ファイル: LicenseTests.cs プロジェクト: smitcham/libpalaso
 public void FromToken_Ask_GiveNullLicense()
 {
     Assert.That(LicenseInfo.FromToken("ask"), Is.InstanceOf <NullLicense>());
 }