summaryrefslogtreecommitdiffstats
path: root/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs
blob: 1138f54d00a4aaec688b605ee3ef0f511aef3352 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;

namespace TwoStepsAuthenticator.UnitTests {
    
    [TestFixture]
    public class UsedCodesManagerTests {

        [Test]
        public void Can_add_codes() {
            var manager = new UsedCodesManager();

            Assert.IsFalse(manager.IsCodeUsed(42uL, "def"));
            manager.AddCode(42uL, "def");
            Assert.IsTrue(manager.IsCodeUsed(42uL, "def"));
        }

    }

    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;
        }
    }
}