summaryrefslogtreecommitdiffstats
path: root/TwoStepsAuthenticator.UnitTests
diff options
context:
space:
mode:
Diffstat (limited to 'TwoStepsAuthenticator.UnitTests')
-rw-r--r--TwoStepsAuthenticator.UnitTests/MockUsedCodesManager.cs16
-rw-r--r--TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs31
-rw-r--r--TwoStepsAuthenticator.UnitTests/TwoStepsAuthenticator.UnitTests.csproj1
-rw-r--r--TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs14
4 files changed, 36 insertions, 26 deletions
diff --git a/TwoStepsAuthenticator.UnitTests/MockUsedCodesManager.cs b/TwoStepsAuthenticator.UnitTests/MockUsedCodesManager.cs
new file mode 100644
index 0000000..cb0065f
--- /dev/null
+++ b/TwoStepsAuthenticator.UnitTests/MockUsedCodesManager.cs
@@ -0,0 +1,16 @@
+namespace TwoStepsAuthenticator.UnitTests
+{
+ internal class MockUsedCodesManager : IUsedCodesManager {
+ public ulong? LastChallenge { get; private set; }
+ public string LastCode { get; private set; }
+
+ public void AddCode(ulong challenge, string code) {
+ this.LastChallenge = challenge;
+ this.LastCode = code;
+ }
+
+ public bool IsCodeUsed(ulong challenge, string code) {
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs b/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
index 1a1ffc6..55be883 100644
--- a/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
+++ b/TwoStepsAuthenticator.UnitTests/TimeAuthenticatorTests.cs
@@ -4,20 +4,24 @@ using System.Linq;
using System.Text;
using NUnit.Framework;
-namespace TwoStepsAuthenticator.UnitTests {
-
+namespace TwoStepsAuthenticator.UnitTests
+{
+
[TestFixture]
- public class TimeAuthenticatorTests {
+ public class TimeAuthenticatorTests
+ {
private MockUsedCodesManager mockUsedCodesManager { get; set; }
[SetUp]
- public void SetUp() {
+ public void SetUp()
+ {
this.mockUsedCodesManager = new MockUsedCodesManager();
}
[Test]
- public void CreateKey() {
- var authenticator = new TimeAuthenticator(usedCodeManager: mockUsedCodesManager);
+ public void CreateKey()
+ {
+ var authenticator = new TimeAuthenticator(mockUsedCodesManager);
var secret = Authenticator.GenerateKey();
var code = authenticator.GetCode(secret);
@@ -25,9 +29,10 @@ namespace TwoStepsAuthenticator.UnitTests {
}
[Test]
- public void Uses_usedCodesManager() {
+ public void Uses_usedCodesManager()
+ {
var date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- var authenticator = new TimeAuthenticator(() => date, usedCodeManager: mockUsedCodesManager);
+ var authenticator = new TimeAuthenticator(mockUsedCodesManager, () => date);
var secret = Authenticator.GenerateKey();
var code = authenticator.GetCode(secret);
@@ -41,18 +46,20 @@ namespace TwoStepsAuthenticator.UnitTests {
[TestCase("DRMK64PPMMC7TDZF", "2013-12-04 18:33:01 +0100", "661188")]
[TestCase("EQOGSM3XZUH6SE2Y", "2013-12-04 18:34:56 +0100", "256804")]
[TestCase("4VU7EQACVDMFJSBG", "2013-12-04 18:36:16 +0100", "800872")]
- public void VerifyKeys(string secret, string timeString, string code) {
+ public void VerifyKeys(string secret, string timeString, string code)
+ {
var date = DateTime.Parse(timeString);
- var authenticator = new TimeAuthenticator(() => date, usedCodeManager: mockUsedCodesManager);
+ var authenticator = new TimeAuthenticator(mockUsedCodesManager, () => date);
Assert.IsTrue(authenticator.CheckCode(secret, code));
}
[Test]
- public void VerifyUsedTime() {
+ public void VerifyUsedTime()
+ {
var date = DateTime.Parse("2013-12-05 17:23:50 +0100");
- var authenticator = new TimeAuthenticator(() => date, usedCodeManager: mockUsedCodesManager);
+ var authenticator = new TimeAuthenticator(mockUsedCodesManager, () => date);
DateTime usedTime;
diff --git a/TwoStepsAuthenticator.UnitTests/TwoStepsAuthenticator.UnitTests.csproj b/TwoStepsAuthenticator.UnitTests/TwoStepsAuthenticator.UnitTests.csproj
index aa38917..38fce5d 100644
--- a/TwoStepsAuthenticator.UnitTests/TwoStepsAuthenticator.UnitTests.csproj
+++ b/TwoStepsAuthenticator.UnitTests/TwoStepsAuthenticator.UnitTests.csproj
@@ -51,6 +51,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CounterAuthenticatorTests.cs" />
+ <Compile Include="MockUsedCodesManager.cs" />
<Compile Include="TimeAuthenticatorTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UsedCodesManagerTests.cs" />
diff --git a/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs b/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs
index 1138f54..15ae91e 100644
--- a/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs
+++ b/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs
@@ -20,18 +20,4 @@ namespace TwoStepsAuthenticator.UnitTests {
}
}
-
- internal class MockUsedCodesManager : IUsedCodesManager {
- public ulong? LastChallenge { get; private set; }
- public string LastCode { get; private set; }
-
- public void AddCode(ulong challenge, string code) {
- this.LastChallenge = challenge;
- this.LastCode = code;
- }
-
- public bool IsCodeUsed(ulong challenge, string code) {
- return false;
- }
- }
}