-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathValidationHelperTests.cs
More file actions
78 lines (68 loc) · 2.38 KB
/
ValidationHelperTests.cs
File metadata and controls
78 lines (68 loc) · 2.38 KB
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
75
76
77
78
namespace NHS.CohortManager.Tests.Shared;
using Common;
[TestClass]
public class ValidationHelperTests
{
[TestMethod]
[DataRow("20000101")] // yyyymmdd
[DataRow("200001")] // yyyymm
[DataRow("2000-01-01")] // yyyy-mm-dd
[DataRow("01/01/2000 12:00:00")] // dd/mm/yyyy hh:mm:ss
[DataRow("2000")] // yyyy
public void ValidatePastDate_ValidInput_ReturnTrue(string date)
{
//No Arrange
//Act
var actual = ValidationHelper.ValidatePastDate(date);
//Assert
bool expected = true;
Assert.AreEqual(actual, expected);
}
[TestMethod]
[DataRow(null)] // null
[DataRow("20300101")] // future date
[DataRow("2000-01-32")] // date doesn't exist
[DataRow("1/13/2000 12:00:00 01")] // d/mm/yyyy hh:mm:ss tt
[DataRow("01/01/2000 25:00:00 01")] // dd/mm/yyyy hh:mm:ss tt
[DataRow("-2000")] // negative year
public void ValidatePastDate_InvalidInput_ReturnFalse(string date)
{
//No Arrange
//Act
var actual = ValidationHelper.ValidatePastDate(date);
//Assert
bool expected = false;
Assert.AreEqual(actual, expected);
}
[TestMethod]
[DataRow("8919361401")] // These are random valid NHS numbers created by https://data-gorilla.uk/en/healthcare/nhs-number/
[DataRow("4539728490")] // This does not contain PII.
[DataRow("1056154497")]
[DataRow("1201484383")]
[DataRow("8325769629")]
public void ValidateNHSNumber_ValidInput_ReturnTrue(string nhsNumber)
{
//No Arrange
//Act
var actual = ValidationHelper.ValidateNHSNumber(nhsNumber);
//Assert
bool expected = true;
Assert.AreEqual(actual, expected);
}
[TestMethod]
[DataRow(null)]
[DataRow("1234567890")]
[DataRow("-1234567890")]
[DataRow("1a2b3c4d5e")]
[DataRow("123")]
[DataRow("0000000000")]
public void ValidateNHSNumber_InvalidInput_ReturnFalse(string nhsNumber)
{
//No Arrange
//Act
var actual = ValidationHelper.ValidateNHSNumber(nhsNumber);
//Assert
bool expected = false;
Assert.AreEqual(actual, expected);
}
}