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 |
#region Using Statements
using System;
using NUnit.Framework;
using StructuredWeb.Domain.Business;
using StructuredWeb.Domain.Business.Component;
using StructuredWeb.Modules;
using StructuredWeb.ValidationFramework;
#endregion
namespace ValidationFrameworkTest
{
/// <summary>
///This is a test class for EmployeeValidatorTest and is intended
///to contain all EmployeeValidatorTest Unit Tests
///</summary>
[TestFixture]
public class EmployeeValidatorTest
{
#region Setup/Teardown
[SetUp]
public void SetUp()
{
}
[TestFixtureSetUp]
public void TestFixtureSetup()
{
StructureMapBootstrapper.Start(false);
}
#endregion
#region Test Methods
[Test]
public void InvalidEmployeeTest()
{
var employee = new Employee {Person = new Person {FirstName = string.Empty, LastName = string.Empty}};
var results = ValidationFactory.Validate(employee);
Assert.IsNotNull(results);
Assert.IsFalse(results.Valid);
Assert.IsTrue(results.Messages.Count > 0);
}
[Test]
public void ValidEmployeeTest()
{
var employee = new Employee {Person = new Person {FirstName = "Bob", LastName = "Bob"}};
var results = ValidationFactory.Validate(employee);
Assert.IsNotNull(results);
Assert.IsTrue(results.Valid);
Assert.IsTrue(results.Messages.Count == 0);
}
[Test]
public void ValidEmployeeWithWarningsTest()
{
var employee = new Employee {Person = new Person {FirstName = "Bob", LastName = "Bob"}, HireDate = new DateTime(3112, 3, 12)};
var results = ValidationFactory.Validate(employee);
Assert.IsNotNull(results);
Assert.IsTrue(results.Valid);
Assert.IsTrue(results.Messages.Count > 0);
}
#endregion
}
} |