-
Notifications
You must be signed in to change notification settings - Fork 0
/
CampusValidatorTests.cs
85 lines (72 loc) · 2.24 KB
/
CampusValidatorTests.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
75
76
77
78
79
80
81
82
83
84
85
using System;
using Athena.Core.Models;
using AutoFixture;
using FluentValidation;
using FluentValidation.TestHelper;
using Xunit;
namespace Athena.Core.Validation.Tests
{
public class CampusValidatorTests : UniqueObjectValidatorTest<Campus>
{
public CampusValidatorTests() : base(new CampusValidator())
{
}
[Fact]
public void Valid()
{
var arg = new Campus
{
Id = Guid.NewGuid(),
Name = "UPRC",
Description = "University Partnership Ridge Campus",
Location = "32121 Lorain Rd, North Ridgeville, OH 44039"
};
Assert.True(_sut.Validate(arg).IsValid);
}
[Fact]
public void NameCannotBeNull()
{
var arg = _fixture.Build<Campus>()
.WithAutoProperties()
.With(c => c.Name, null)
.Create();
_sut.ShouldHaveValidationErrorFor(c => c.Name, arg);
}
[Fact]
public void NameCannotBeEmpty()
{
var arg = _fixture.Build<Campus>()
.WithAutoProperties()
.With(c => c.Name, string.Empty)
.Create();
_sut.ShouldHaveValidationErrorFor(c => c.Name, arg);
}
[Fact]
public void DescriptionCannotBeNull()
{
var arg = _fixture.Build<Campus>()
.WithAutoProperties()
.With(c => c.Description, null)
.Create();
_sut.ShouldHaveValidationErrorFor(c => c.Description, arg);
}
[Fact]
public void LocationCannotBeNull()
{
var arg = _fixture.Build<Campus>()
.WithAutoProperties()
.With(c => c.Location, null)
.Create();
_sut.ShouldHaveValidationErrorFor(c => c.Location, arg);
}
[Fact]
public void LocationCannotBeEmpty()
{
var arg = _fixture.Build<Campus>()
.WithAutoProperties()
.With(c => c.Location, string.Empty)
.Create();
_sut.ShouldHaveValidationErrorFor(c => c.Location, arg);
}
}
}