-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOfferingValidatorTests.cs
68 lines (61 loc) · 2.17 KB
/
OfferingValidatorTests.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
using System;
using System.Linq;
using Athena.Core.Models;
using AutoFixture;
using FluentValidation.TestHelper;
using Xunit;
namespace Athena.Core.Validation.Tests
{
public class OfferingValidatorTests : UniqueObjectValidatorTest<Offering>
{
public OfferingValidatorTests() : base(new OfferingValidator(new CampusValidator(), new CourseValidator(new InstitutionValidator()), new MeetingValidator()))
{
}
[Fact]
public void Valid()
{
var arg = new Offering
{
Id = Guid.NewGuid(),
Course = new Course
{
Id = Guid.NewGuid(),
Name = "EECS 4020",
Institution = new Institution
{
Id = Guid.NewGuid(),
Name = "The University of Toledo",
Description = ""
}
},
Start = DateTime.Today,
End = DateTime.Today.AddDays(80),
Campus = new Campus
{
Id = Guid.NewGuid(),
Name = "UPRC",
Description = "University Partnership Ridge Campus",
Location = "32121 Lorain Rd, North Ridgeville, OH 44039"
},
Meetings = Enumerable.Empty<Meeting>()
};
Assert.True(_sut.Validate(arg).IsValid);
}
[Fact]
public void UsesCampusValidatorForCampus() =>
_sut.ShouldHaveChildValidator(o => o.Campus, typeof(CampusValidator));
[Fact]
public void UsesCourseValidatorForCourse() =>
_sut.ShouldHaveChildValidator(o => o.Course, typeof(CourseValidator));
[Fact]
public void EndDateCannotBeBeforeStartDate()
{
var arg = _fixture.Build<Offering>()
.WithAutoProperties()
.With(o => o.Start, DateTime.Today)
.With(o => o.End, DateTime.Today.AddDays(-80))
.Create();
_sut.ShouldHaveValidationErrorFor(o => o.End, arg);
}
}
}