-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLetterSequenceCheckTest.cs
60 lines (52 loc) · 1.83 KB
/
LetterSequenceCheckTest.cs
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using EzPasswordValidator.Checks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EzPasswordValidator.Tests
{
[TestClass]
public class LetterSequenceCheckTest
{
private LetterSequenceCheck _check;
[TestInitialize]
public void Setup() => _check = new LetterSequenceCheck();
[DataRow("abcd")]
[DataRow("testbcde")]
[DataRow("wxyz")]
[DataRow("efghtest")]
[DataTestMethod]
public void WhenPasswordContainsMostCommonThreeLetterSequencesThenPasswordIsInvalid(string psw) =>
Assert.IsFalse(_check.Execute(psw));
/// <summary>
/// This test assumes that the default sequence length is 4.
/// </summary>
[DataRow("abcd")]
[DataRow("testbcde")]
[DataRow("WXYZ")]
[DataRow("efghijkXYZ")]
[DataTestMethod]
public void WhenPasswordContainsFourLetterSequenceThenPasswordIsInvalid(string psw) =>
Assert.IsFalse(_check.Execute(psw));
/// <summary>
/// This test sets a custom sequence length and checks that the
/// password with a sequence of that length fails.
/// </summary>
[TestMethod]
public void WhenPasswordContainsCustomLengthLetterSequenceThenPasswordIsInvalid()
{
const string invalidPsw = "abc";
_check.SequenceLength = 3;
Assert.IsFalse(_check.Execute(invalidPsw));
}
[TestMethod]
public void WhenPasswordHasNoLetterSequenceThenPasswordIsValid()
{
const string validPsw = "valid";
Assert.IsTrue(_check.Execute(validPsw));
}
[TestMethod]
public void WhenIncrementingCharByOneThenNextChar()
{
const char c = 'a';
Assert.IsTrue(((int)c + 1) == (int)'b');
}
}
}