-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from livioc/merge_HR_master
Merge with hibernating-rhinos/rhino-licensing master
- Loading branch information
Showing
94 changed files
with
33,650 additions
and
1,313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Rhino-Licensing | ||
A software licensing framework [https://www.hibernatingrhinos.com/oss/rhino-licensing](https://www.hibernatingrhinos.com/oss/rhino-licensing) [http://ayende.com](http://ayende.com) | ||
|
||
how to build | ||
--------------- | ||
The solution can be directly compiled with visual studio | ||
note: the psake build is currently broken | ||
|
||
To create the nuget package run buildNuget.bat | ||
|
||
|
||
how to run the tests | ||
--------------- | ||
Please note that in order to run the tests you must either run them in the context of the administrator or run the following command: | ||
netsh http add urlacl url=http://+:19292/license user=YOUR_USER_NAME | ||
|
||
|
||
acknowledgements | ||
--------------- | ||
Rhino Licensing is making use of the excellent log4net logging framework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+167 Bytes
(210%)
Rhino.Licensing.AdminTool.Tests/Properties/AssemblyInfo.cs
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Rhino.Licensing.AdminTool.Tests/Services/ExpirationDateConverterTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Globalization; | ||
using Rhino.Licensing.AdminTool.ValueConverters; | ||
using Xunit; | ||
|
||
namespace Rhino.Licensing.AdminTool.Tests.Services | ||
{ | ||
public class ExpirationDateConverterTests | ||
{ | ||
[Fact] | ||
public void Returns_Never_If_No_Date_Specified() | ||
{ | ||
var converter = new ExpirationDateConverter(); | ||
|
||
var value = converter.Convert(null, GetType(), null, CultureInfo.InvariantCulture); | ||
|
||
Assert.Equal("Never", value); | ||
} | ||
|
||
[Fact] | ||
public void Convertes_Date_Using_Provided_Culture() | ||
{ | ||
var converter = new ExpirationDateConverter(); | ||
var culture = new CultureInfo("en-au"); | ||
|
||
var value = converter.Convert(new DateTime(2000, 1, 1), GetType(), null, culture); | ||
|
||
Assert.Equal("1/01/2000 12:00 AM", value); | ||
} | ||
|
||
[Fact] | ||
public void Object_Of_Non_Date_Type_Passed_In_Will_Be_Returned() | ||
{ | ||
var converter = new ExpirationDateConverter(); | ||
var culture = new CultureInfo("en-au"); | ||
|
||
var value = converter.Convert("String Value", GetType(), null, culture); | ||
|
||
Assert.Equal("String Value", value); | ||
} | ||
|
||
[Fact] | ||
public void Converts_Date_Using_Invariant_Culture_When_No_Culture_Provided() | ||
{ | ||
var converter = new ExpirationDateConverter(); | ||
CultureInfo culture = null; | ||
|
||
var value = converter.Convert(new DateTime(2000, 1, 1), GetType(), null, culture); | ||
|
||
Assert.Equal("01/01/2000 00:00", value); | ||
} | ||
|
||
[Fact] | ||
public void Does_One_Way_Conversion() | ||
{ | ||
var converter = new ExpirationDateConverter(); | ||
|
||
Assert.Throws<NotImplementedException>(() => converter.ConvertBack(this, typeof(object), this, CultureInfo.InvariantCulture)); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
Rhino.Licensing.AdminTool.Tests/Services/ExportServiceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Rhino.Licensing.AdminTool.Model; | ||
using Rhino.Licensing.AdminTool.Services; | ||
using Xunit; | ||
|
||
namespace Rhino.Licensing.AdminTool.Tests.Services | ||
{ | ||
public class ExportServiceTests | ||
{ | ||
[Fact] | ||
public void Exports_LicenseInfo_To_File() | ||
{ | ||
var service = new ExportService() as IExportService; | ||
var product = new Product { Id = Guid.NewGuid() }; | ||
var license = new License { ID = Guid.NewGuid(), LicenseType = LicenseType.Standard, OwnerName = "License Owner", ExpirationDate = new DateTime(2020, 1, 1) }; | ||
var path = Path.GetTempFileName(); | ||
var file = new FileInfo(path); | ||
|
||
service.Export(product, license, file); | ||
|
||
var reader = file.OpenText(); | ||
var content = reader.ReadToEnd(); | ||
|
||
Assert.NotNull(content); | ||
Assert.Contains("<name>License Owner</name>", content); | ||
Assert.Contains("type=\"Standard\"", content); | ||
Assert.Contains("expiration=\"2020-01-01T00:00:00.0000000\"", content); | ||
} | ||
|
||
[Fact] | ||
public void Exports_With_MaxDate_If_No_Expiration_Date_Is_Set() | ||
{ | ||
var service = new ExportService() as IExportService; | ||
var product = new Product { Id = Guid.NewGuid(), Name = "My Product", }; | ||
var license = new License { ID = Guid.NewGuid(), LicenseType = LicenseType.Standard, OwnerName = "License Owner", ExpirationDate = null }; | ||
var path = Path.GetTempFileName(); | ||
var file = new FileInfo(path); | ||
|
||
service.Export(product, license, file); | ||
|
||
var reader = file.OpenText(); | ||
var content = reader.ReadToEnd(); | ||
|
||
Assert.NotNull(content); | ||
Assert.Contains("expiration=\"9999-12-31T23:59:59.9999999\"", content); | ||
} | ||
|
||
[Fact] | ||
public void Exports_With_User_Defined_KeyValues_When_Available() | ||
{ | ||
var service = new ExportService() as IExportService; | ||
var product = new Product { Id = Guid.NewGuid(), Name = "My Product", }; | ||
var license = new License | ||
{ | ||
LicenseType = LicenseType.Standard, | ||
OwnerName = "License Owner", | ||
ExpirationDate = null, | ||
}; | ||
|
||
license.Data.Add(new UserData { Key = "KeyOne", Value = "ValueOne"}); | ||
license.Data.Add(new UserData { Key = "KeyTwo", Value = "ValueTwo"}); | ||
|
||
var path = Path.GetTempFileName(); | ||
var file = new FileInfo(path); | ||
|
||
service.Export(product, license, file); | ||
|
||
var reader = file.OpenText(); | ||
var content = reader.ReadToEnd(); | ||
|
||
Assert.NotNull(content); | ||
Assert.Contains("KeyOne=\"ValueOne\"", content); | ||
Assert.Contains("KeyTwo=\"ValueTwo\"", content); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
Rhino.Licensing.AdminTool.Tests/ViewModels/AboutViewModelTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Rhino.Licensing.AdminTool.Tests/ViewModels/IssueLicenseViewModelTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Rhino.Licensing.AdminTool.ViewModels; | ||
using Xunit; | ||
|
||
namespace Rhino.Licensing.AdminTool.Tests.ViewModels | ||
{ | ||
public class IssueLicenseViewModelTests | ||
{ | ||
[Fact] | ||
public void Notifies_All_Screen_When_Selected_License_Changes() | ||
{ | ||
var userData = new UserDataViewModel() as IUserDataViewModel; | ||
var licenseInfo = new LicenseInfoViewModel() as ILicenseInfoViewModel; | ||
|
||
var vm = new IssueLicenseViewModel(userData, licenseInfo); | ||
|
||
Assert.Same(vm.CurrentLicense, userData.CurrentLicense); | ||
Assert.Same(vm.CurrentLicense, licenseInfo.CurrentLicense); | ||
} | ||
|
||
[Fact] | ||
public void Closing_ViewModel_Calls_TryClose_With_True_DialogResult() | ||
{ | ||
var userData = new UserDataViewModel() as IUserDataViewModel; | ||
var licenseInfo = new LicenseInfoViewModel() as ILicenseInfoViewModel; | ||
|
||
var vm = new TestableIssueLicenseViewModel(userData, licenseInfo); | ||
vm.Accept(); | ||
|
||
Assert.NotNull(vm.SelectedDialogResult); | ||
Assert.True(vm.SelectedDialogResult.Value); | ||
} | ||
|
||
[Fact] | ||
public void Can_Accept_New_License_When_OwnerName_Is_Filled() | ||
{ | ||
var userData = new UserDataViewModel() as IUserDataViewModel; | ||
var licenseInfo = new LicenseInfoViewModel() as ILicenseInfoViewModel; | ||
|
||
var vm = new TestableIssueLicenseViewModel(userData, licenseInfo); | ||
|
||
var defaultCanAccept = vm.CanAccept; | ||
vm.CurrentLicense.OwnerName = "John Doe"; | ||
var canAccept = vm.CanAccept; | ||
|
||
Assert.False(defaultCanAccept); | ||
Assert.True(canAccept); | ||
} | ||
|
||
private class TestableIssueLicenseViewModel : IssueLicenseViewModel | ||
{ | ||
public TestableIssueLicenseViewModel(IUserDataViewModel userDataViewModel, ILicenseInfoViewModel licenseInfoViewModel) | ||
: base(userDataViewModel, licenseInfoViewModel) | ||
{ | ||
} | ||
|
||
public bool? SelectedDialogResult { get; set; } | ||
|
||
public override void TryClose(bool? dialogResult) | ||
{ | ||
SelectedDialogResult = dialogResult; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.