summaryrefslogtreecommitdiffstats
path: root/TwoStepsAuthenticator.UnitTests/UsedCodesManagerTests.cs
blob: 7b3965005bebe911b5cf61e679d8a7c9b18f95ea (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(42L, "def"));
            manager.AddCode(42L, "def");
            Assert.IsTrue(manager.IsCodeUsed(42L, "def"));
        }

    }

    internal class MockUsedCodesManager : IUsedCodesManager {
        public long? LastChallenge { get; private set; }
        public string LastCode { get; private set; }

        public void AddCode(long challenge, string code) {
            this.LastChallenge = challenge;
            this.LastCode = code;
        }

        public bool IsCodeUsed(long challenge, string code) {
            return false;
        }
    }
}