-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNumberSequenceCheckTest.cs
74 lines (64 loc) · 2.29 KB
/
NumberSequenceCheckTest.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using EzPasswordValidator.Checks;
using EzPasswordValidator.Validators;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EzPasswordValidator.Tests
{
[TestClass]
public class NumberSequenceCheckTest
{
private PasswordValidator _validator;
private NumberSequenceCheck _check;
[TestInitialize]
public void Setup()
{
_validator = new PasswordValidator();
_validator.AddCheck(CheckTypes.NumberSequence);
_check = new NumberSequenceCheck();
}
[TestMethod]
public void WhenPasswordContainsNoNumbersThenPasswordIsValid()
{
const string psw = "test";
Assert.IsTrue(_check.Execute(psw));
}
[DataRow("123test")]
[DataRow("te123st")]
[DataRow("test123")]
[DataTestMethod]
public void WhenPasswordContainsAThreeDigitNumberSequenceThenPasswordIsValid(string psw) =>
Assert.IsTrue(_check.Execute(psw));
[DataRow("2345test")]
[DataRow("te2345st")]
[DataRow("test2345")]
[DataTestMethod]
public void WhenPasswordContainsAFourDigitNumberSequenceThenPasswordIsInvalid(string psw) =>
Assert.IsFalse(_check.Execute(psw));
[DataRow("6543test")]
[DataRow("te6543st")]
[DataRow("test6543")]
[DataTestMethod]
public void WhenPasswordContainsAFourDigitReverseNumberSequenceThenPasswordIsInvalid(string psw) =>
Assert.IsFalse(_check.Execute(psw));
[TestMethod]
public void DefaultLengthIsFour() =>
Assert.IsTrue(_validator.NumberSequenceLength == 4);
[DataRow("6543test")]
[DataRow("te6543st")]
[DataRow("test1234")]
[DataRow("test")]
[DataTestMethod]
public void ChangingSequenceLengthToFiveAllowsSequencesOfLowerLength(string psw)
{
_validator.NumberSequenceLength = 5;
Assert.IsTrue(_validator.Validate(psw));
}
[DataRow("te98765st")]
[DataRow("test12345")]
[DataTestMethod]
public void ChangingSequenceLengthToFiveDisallowsSequencesOfLengthFive(string psw)
{
_validator.NumberSequenceLength = 5;
Assert.IsFalse(_validator.Validate(psw));
}
}
}