Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/AuthorizationTestBase.cs =================================================================== diff -u -r4047 -r4070 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/AuthorizationTestBase.cs (.../AuthorizationTestBase.cs) (revision 4047) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/AuthorizationTestBase.cs (.../AuthorizationTestBase.cs) (revision 4070) @@ -33,28 +33,14 @@ public abstract class AuthorizationTestBase { private const string LicenseNotFoundMessage = "could not checkout/borrow license"; - /// - /// Gets the feature name for that exists. - /// - public abstract string GetFeature(); - /// - /// Gets the version for that exists for feature returned - /// by . - /// - public abstract IEnumerable GetSupportedFeatureVersions(); - /// - /// Gets the version for that do not exists for feature - /// returned by . - /// - public abstract IEnumerable GetUnsupportedFeatureVersions(); [Test] public void TestInteropDAuthPublicKey() { const string expected = "379d563066715186"; - var asm = Assembly.GetAssembly(typeof (DAuthClient)); - var pktb = asm.GetName().GetPublicKeyToken(); - var pkt = BitConverter.ToString(pktb).Replace("-", "").ToLowerInvariant(); + var asm = Assembly.GetAssembly(typeof(DAuthClient)); + byte[] pktb = asm.GetName().GetPublicKeyToken(); + string pkt = BitConverter.ToString(pktb).Replace("-", "").ToLowerInvariant(); Assert.AreEqual(expected, pkt); } @@ -64,7 +50,7 @@ using (var aw = new DAuthClient(false, true)) { Assert.IsFalse(aw.CheckOut("NotFound", "1.0")); - var errorMessage = aw.GetLastErrorMessage(); + string errorMessage = aw.GetLastErrorMessage(); Assert.IsTrue(errorMessage.Contains(LicenseNotFoundMessage)); } } @@ -74,17 +60,18 @@ { using (var aw = new DAuthClient(false, true)) { - var feature = GetFeature(); - foreach (var supportedFeatureVersion in GetSupportedFeatureVersions()) + string feature = GetFeature(); + foreach (string supportedFeatureVersion in GetSupportedFeatureVersions()) { Assert.IsTrue(aw.CheckOut(feature, supportedFeatureVersion), - string.Format("{0} - {1} not accepted.", feature, supportedFeatureVersion)); + string.Format("{0} - {1} not accepted.", feature, supportedFeatureVersion)); } - foreach (var unsupportedFeatureVersion in GetUnsupportedFeatureVersions()) + + foreach (string unsupportedFeatureVersion in GetUnsupportedFeatureVersions()) { Assert.IsFalse(aw.CheckOut(feature, unsupportedFeatureVersion), - string.Format("{0} - {1} accepted while it shouldn't.", feature, unsupportedFeatureVersion)); - var errorMessage = aw.GetLastErrorMessage(); + string.Format("{0} - {1} accepted while it shouldn't.", feature, unsupportedFeatureVersion)); + string errorMessage = aw.GetLastErrorMessage(); Assert.IsTrue(errorMessage.Contains(LicenseNotFoundMessage)); } } @@ -105,7 +92,7 @@ { using (var aw = new DAuthClient(false, true)) { - String awres = ""; + var awres = ""; Assert.IsTrue(aw.GetVendor(GetFeature(), ref awres)); Assert.AreEqual("Deltares", awres); } @@ -116,7 +103,7 @@ { using (var aw = new DAuthClient(false, true)) { - String awres = ""; + var awres = ""; Assert.IsTrue(aw.GetDistributor(GetFeature(), ref awres)); Assert.AreEqual("Deltares", awres); } @@ -151,11 +138,11 @@ { int firstCount = -1; aw.GetCount(GetFeature(), ref firstCount); - + Assert.IsTrue(aw.CheckOut(GetFeature(), GetSupportedFeatureVersions().First())); int secondCount = -1; aw.GetCount(GetFeature(), ref secondCount); - Assert.AreEqual(firstCount+1, secondCount); + Assert.AreEqual(firstCount + 1, secondCount); Assert.IsTrue(aw.CheckIn(GetFeature())); aw.GetCount(GetFeature(), ref secondCount); Assert.AreEqual(firstCount, secondCount); @@ -167,7 +154,7 @@ { using (var aw = new DAuthClient(false, true)) { - DateTime expiration = new DateTime(1900, 1, 1, 0, 0, 0); + var expiration = new DateTime(1900, 1, 1, 0, 0, 0); aw.GetExpiration(GetFeature(), ref expiration); Assert.AreEqual(2000, expiration.Year); } @@ -180,7 +167,7 @@ { String[] currentUsers = null; - var feature = GetFeature(); + string feature = GetFeature(); Assert.IsTrue(aw.CheckOut(feature, GetSupportedFeatureVersions().First())); Assert.IsTrue(aw.GetCurrentUsers(feature, ref currentUsers)); Assert.IsNotEmpty(currentUsers); @@ -195,7 +182,7 @@ using (var aw = new DAuthClient(false, true)) { int count = -1; - var feature = GetFeature(); + string feature = GetFeature(); Assert.IsTrue(aw.GetUsedLicenses(feature, Environment.UserName, ref count)); Assert.AreEqual(0, count); @@ -225,7 +212,7 @@ String[] features = null; Assert.IsTrue(aw.GetAvailableFeatures(ref features)); Assert.IsNotEmpty(features); - var feature = GetFeature(); + string feature = GetFeature(); Assert.IsTrue(features.Any(f => f == feature)); } } @@ -235,7 +222,7 @@ { using (var aw = new DAuthClient(false, true)) { - bool isServer = false; + var isServer = false; Assert.IsTrue(aw.IsServer(GetFeature(), ref isServer)); Assert.IsTrue(isServer); } @@ -248,8 +235,8 @@ // average 3 calls per second using (var aw = new DAuthClient(false, true)) { - var feature = GetFeature(); - var version = GetSupportedFeatureVersions().First(); + string feature = GetFeature(); + string version = GetSupportedFeatureVersions().First(); var stopwatch = new Stopwatch(); stopwatch.Start(); for (var i = 0; i < 10; i++) @@ -258,9 +245,27 @@ Assert.IsTrue(aw.CheckIn(feature)); Console.Error.WriteLine("Round :" + i); } + stopwatch.Stop(); - Assert.Less(stopwatch.Elapsed, new TimeSpan(0,0,0,3)); + Assert.Less(stopwatch.Elapsed, new TimeSpan(0, 0, 0, 3)); } } + + /// + /// Gets the feature name for that exists. + /// + public abstract string GetFeature(); + + /// + /// Gets the version for that exists for feature returned + /// by . + /// + public abstract IEnumerable GetSupportedFeatureVersions(); + + /// + /// Gets the version for that do not exists for feature + /// returned by . + /// + public abstract IEnumerable GetUnsupportedFeatureVersions(); } } \ No newline at end of file