Permalink
Browse files

Update SL5 licensing tests

  • Loading branch information...
1 parent 01b3b78 commit fbdcaa9672d33c0b4e091a3c83ddd9354201856a @mythz mythz committed Jan 7, 2014
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Text.SL5", "ServiceStack.Text\ServiceStack.Text.SL5.csproj", "{3D4C3068-78B4-4012-A5F2-5104E01ACB8A}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Text.SL5", "ServiceStack.Text\ServiceStack.Text.SL5.csproj", "{579B3FDB-CDAD-44E1-8417-885C38E49A0E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Text.SL5.Tests", "..\tests\ServiceStack.Text.SL5.Tests\ServiceStack.Text.SL5.Tests.csproj", "{227ABF79-D20A-4655-870D-3BBE10894A99}"
EndProject
@@ -11,10 +11,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3D4C3068-78B4-4012-A5F2-5104E01ACB8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3D4C3068-78B4-4012-A5F2-5104E01ACB8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3D4C3068-78B4-4012-A5F2-5104E01ACB8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3D4C3068-78B4-4012-A5F2-5104E01ACB8A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {579B3FDB-CDAD-44E1-8417-885C38E49A0E}.Release|Any CPU.Build.0 = Release|Any CPU
{227ABF79-D20A-4655-870D-3BBE10894A99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{227ABF79-D20A-4655-870D-3BBE10894A99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{227ABF79-D20A-4655-870D-3BBE10894A99}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -1,115 +0,0 @@
-// Copyright (c) Service Stack LLC. All Rights Reserved.
-// License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt
-
-using System;
-using System.Collections;
-using System.ComponentModel;
-using NUnit.Framework;
-
-namespace ServiceStack.Text.Tests
-{
- public class LicenseUseCase
- {
- public LicenseUseCase(LicenseFeature licenseFeature, QuotaType quotaType, int allowedLimit)
- {
- Feature = licenseFeature;
- QuotaType = quotaType;
- AllowedLimit = allowedLimit;
- }
-
- public LicenseFeature Feature { get; set; }
- public QuotaType QuotaType { get; set; }
- public int AllowedLimit { get; set; }
- }
-
- [TestFixture]
- public class LicensingTests
- {
- const string TestBusiness2000Text = "1001-e1JlZjoxMDAxLE5hbWU6VGVzdCBCdXNpbmVzcyxUeXBlOkJ1c2luZXNzLEhhc2g6T3dIRSt5T1FOV2NmYzZWWGpXd09QN3Y3L3Z2a09vWFUrN0FZUm5RZis1bXNTenpkejFSQnJUUzltQXZHNkV1SjVUTTMzR2JhZXZ5OENVQ08rRXZoSTlmeXo5SGt6bm5HekVmakh5U3VXM3JQc1ZmVHRqclJzTVZBOWYrNGMyUk1wUnlHOWVWRmVUR3lodXpvQ1JCODdlRXZDWTc4K0hLUkxpNHd3ZUNTakFrPSxFeHBpcnk6MjAwMC0wMS0wMX0=";
- readonly LicenseKey TestBusiness2000 = new LicenseKey { Ref = "1001", Name = "Test Business", Type = LicenseType.Business, Expiry = new DateTime(2000, 01, 01) };
- const string TestIndie2000Text = "1001-e1JlZjoxMDAxLE5hbWU6VGVzdCBJbmRpZSxUeXBlOkluZGllLEhhc2g6RTUzckttMEtDRWsvbzBEQWNicUNKSFVwRG1jZjV0akc4YUFzVnIvWnorTGovdzBnWW4xY0FJRTh5T2hjUjBZNG56eE9yd3FQdVFSTy9qeGl5dlI5RmZwamc4U05ud0ppUW9DMlRhU3RNaEkwV1loVXA1Umc2bjJFeG1JdWViRFJ0a21DaFFFZHlXQTdid0pGOUFualFHQ1RCZ0w2UDUyL2o1cGFnQytKQS84PSxFeHBpcnk6MjAwMC0wMS0wMX0=";
- readonly LicenseKey TestIndie2000 = new LicenseKey { Ref = "1001", Name = "Test Indie", Type = LicenseType.Indie, Expiry = new DateTime(2000, 01, 01) };
- private const string TestBusiness2014Text = "1001-e1JlZjoxMDAxLE5hbWU6VGVzdCBCdXNpbmVzcyxUeXBlOkJ1c2luZXNzLEhhc2g6T3dIRSt5T1FOV2NmYzZWWGpXd09QN3Y3L3Z2a09vWFUrN0FZUm5RZis1bXNTenpkejFSQnJUUzltQXZHNkV1SjVUTTMzR2JhZXZ5OENVQ08rRXZoSTlmeXo5SGt6bm5HekVmakh5U3VXM3JQc1ZmVHRqclJzTVZBOWYrNGMyUk1wUnlHOWVWRmVUR3lodXpvQ1JCODdlRXZDWTc4K0hLUkxpNHd3ZUNTakFrPSxFeHBpcnk6MjAxNC0wMS0wMX0=";
- readonly LicenseKey TestBusiness2014 = new LicenseKey { Ref = "1001", Name = "Test Business", Type = LicenseType.Business, Expiry = new DateTime(2014, 01, 01) };
- const string TestIndie2014Text = "1001-e1JlZjoxMDAxLE5hbWU6VGVzdCBJbmRpZSxUeXBlOkluZGllLEhhc2g6RTUzckttMEtDRWsvbzBEQWNicUNKSFVwRG1jZjV0akc4YUFzVnIvWnorTGovdzBnWW4xY0FJRTh5T2hjUjBZNG56eE9yd3FQdVFSTy9qeGl5dlI5RmZwamc4U05ud0ppUW9DMlRhU3RNaEkwV1loVXA1Umc2bjJFeG1JdWViRFJ0a21DaFFFZHlXQTdid0pGOUFualFHQ1RCZ0w2UDUyL2o1cGFnQytKQS84PSxFeHBpcnk6MjAxNC0wMS0wMX0=";
- readonly LicenseKey TestIndie2014 = new LicenseKey { Ref = "1001", Name = "Test Indie", Type = LicenseType.Indie, Expiry = new DateTime(2014, 01, 01) };
-
- public IEnumerable AllLicenseUseCases
- {
- get
- {
- return new[]
- {
- new LicenseUseCase(LicenseFeature.Text, QuotaType.Types, LicenseUtils.FreeQuotas.TextTypes),
- new LicenseUseCase(LicenseFeature.Redis, QuotaType.Types, LicenseUtils.FreeQuotas.RedisTypes),
- new LicenseUseCase(LicenseFeature.OrmLite, QuotaType.Tables, LicenseUtils.FreeQuotas.OrmLiteTables),
- new LicenseUseCase(LicenseFeature.ServiceStack, QuotaType.Operations, LicenseUtils.FreeQuotas.ServiceStackOperations),
- new LicenseUseCase(LicenseFeature.Admin, QuotaType.PremiumFeature, LicenseUtils.FreeQuotas.PremiumFeature),
- new LicenseUseCase(LicenseFeature.Premium, QuotaType.PremiumFeature, LicenseUtils.FreeQuotas.PremiumFeature),
- };
- }
- }
-
- [Test, TestCaseSource("AllLicenseUseCases")]
- public void Allows_access_to_all_use_cases_with_All_License(LicenseUseCase licenseUseCase)
- {
- LicenseUtils.ApprovedUsage(LicenseFeature.All, licenseUseCase.Feature, licenseUseCase.AllowedLimit, int.MinValue, "Failed");
- LicenseUtils.ApprovedUsage(LicenseFeature.All, licenseUseCase.Feature, licenseUseCase.AllowedLimit, 0, "Failed");
- LicenseUtils.ApprovedUsage(LicenseFeature.All, licenseUseCase.Feature, licenseUseCase.AllowedLimit, int.MaxValue, "Failed");
- }
-
- [Test, TestCaseSource("AllLicenseUseCases")]
- public void Allows_access_on_all_use_cases_with_no_or_max_allowed_usage_and_no_license(LicenseUseCase licenseUseCase)
- {
- LicenseUtils.ApprovedUsage(LicenseFeature.None, licenseUseCase.Feature, licenseUseCase.AllowedLimit, int.MinValue, "Failed");
- LicenseUtils.ApprovedUsage(LicenseFeature.None, licenseUseCase.Feature, licenseUseCase.AllowedLimit, 0, "Failed");
- LicenseUtils.ApprovedUsage(LicenseFeature.None, licenseUseCase.Feature, licenseUseCase.AllowedLimit, licenseUseCase.AllowedLimit, "Failed");
- }
-
- [Test, TestCaseSource("AllLicenseUseCases")]
- public void Throws_on_all_use_cases_with_exceeded_usage_and_no_license(LicenseUseCase licenseUseCase)
- {
- Assert.Throws<LicenseException>(() =>
- LicenseUtils.ApprovedUsage(LicenseFeature.None, licenseUseCase.Feature, licenseUseCase.AllowedLimit, licenseUseCase.AllowedLimit + 1, "Failed"));
-
- Assert.Throws<LicenseException>(() =>
- LicenseUtils.ApprovedUsage(LicenseFeature.None, licenseUseCase.Feature, licenseUseCase.AllowedLimit, int.MaxValue, "Failed"));
- }
-
- [Test]
- public void Can_register_valid_licenses()
- {
- Licensing.RegisterLicense(TestBusiness2014Text);
- Assert.That(LicenseUtils.ActivatedLicenseFeatures(), Is.EqualTo(LicenseFeature.Business));
-
- Licensing.RegisterLicense(TestIndie2014Text);
- Assert.That(LicenseUtils.ActivatedLicenseFeatures(), Is.EqualTo(LicenseFeature.Indie));
- }
-
- [Test]
- public void Expired_licenses_throws_LicenseException()
- {
- try
- {
- Licensing.RegisterLicense(TestBusiness2000Text);
- Assert.Fail("Should throw Expired LicenseException");
- }
- catch (LicenseException ex)
- {
- ex.Message.Print();
- Assert.That(ex.Message, Is.StringStarting("This license has expired"));
- }
-
- try
- {
- Licensing.RegisterLicense(TestBusiness2000Text);
- Assert.Fail("Should throw Expired LicenseException");
- }
- catch (LicenseException ex)
- {
- ex.Message.Print();
- Assert.That(ex.Message, Is.StringStarting("This license has expired"));
- }
- }
- }
-}
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DefineConstants>TRACE;DEBUG;SL5</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@@ -44,7 +44,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="LicensingTests.cs" />
+ <Compile Include="..\ServiceStack.Text.Tests\LicensingTests.cs">
+ <Link>LicensingTests.cs</Link>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -4,7 +4,6 @@
using System;
using System.Collections;
using NUnit.Framework;
-using ServiceStack.Configuration;
namespace ServiceStack.Text.Tests
{
@@ -89,7 +88,8 @@ public void Can_register_valid_licenses()
[Test]
public void Can_register_valid_license()
{
- Licensing.RegisterLicense(new AppSettings().GetString("servicestack:license"));
+ //Licensing.RegisterLicense(new AppSettings().GetString("servicestack:license"));
+ Licensing.RegisterLicense("1001-e1JlZjoxMDAxLE5hbWU6VGVzdCBCdXNpbmVzcyxUeXBlOkJ1c2luZXNzLEhhc2g6UHVNTVRPclhvT2ZIbjQ5MG5LZE1mUTd5RUMzQnBucTFEbTE3TDczVEF4QUNMT1FhNXJMOWkzVjFGL2ZkVTE3Q2pDNENqTkQyUktRWmhvUVBhYTBiekJGUUZ3ZE5aZHFDYm9hL3lydGlwUHI5K1JsaTBYbzNsUC85cjVJNHE5QVhldDN6QkE4aTlvdldrdTgyTk1relY2eis2dFFqTThYN2lmc0JveHgycFdjPSxFeHBpcnk6MjAxMy0wMS0wMX0=");
Assert.That(LicenseUtils.ActivatedLicenseFeatures(), Is.EqualTo(LicenseFeature.Business));
}

0 comments on commit fbdcaa9

Please sign in to comment.