public void SetUp() { _eventBroker = Substitute.For<IEventBroker>(); DomainEvents.SetEventBrokerStrategy(_eventBroker); _fred = new Student(); _law = new Subject(); // Act _fred.EnrolIn(_law); }
internal void AcceptEnrolmentFor(Student student) { if (IsEnrolled(student)) throw new InvalidOperationException("Student is already enrolled."); StudentSubjectEnrolments.Add(new StudentSubjectEnrolment { Student = student, Subject = this, }); DomainEvents.Raise(new StudentEnrolledInSubjectEvent(student, this)); }
public void TheyShouldNotBePermitted() { var fred = new Student(); var law = new Subject { MaxStudents = 0, }; fred.EnrolIn(law); Assert.Inconclusive("This is our mission for tomorrow morning. We need to add a non-default constructor to our entity so that we can reliably create instances in a valid state."); }
private bool IsEnrolled(Student student) { return StudentSubjectEnrolments .Where(sse => sse.StudentId == student.Id) .Any(); }
partial void DeleteStudent(Student instance);
partial void UpdateStudent(Student instance);
partial void InsertStudent(Student instance);