コード例 #1
0
        public void Should_update_the_attendee_count_when_adding_an_attendee()
        {
            var conference = new Conference("Something");

            var attendee = new Attendee("Foo", "Bar");

            attendee.RegisterFor(conference);

            conference.AttendeeCount.ShouldEqual(1);
        }
コード例 #2
0
        public void Should_create_attendee_association_when_registering_for_an_event()
        {
            var conference = new Conference("Austin Code Camp");
            var attendee   = new Attendee("Joe", "Schmoe");

            attendee.RegisterFor(conference);

            attendee.Conference.ShouldEqual(conference);
            conference.GetAttendees().Any(a => a == attendee).ShouldBeTrue();
        }
コード例 #3
0
        public void Should_cascade_attendee()
        {
            var attendee = new Attendee("Joe", "Schmoe");
            var newEvent = new Conference("Some event");

            attendee.RegisterFor(newEvent);

            SaveEntities(newEvent);

            var loaded = SessionSource.CreateSession().Load <Conference>(newEvent.Id);

            loaded.GetAttendees().Count().ShouldEqual(1);
            loaded.GetAttendees().ElementAt(0).Conference.ShouldEqual(loaded);
        }
コード例 #4
0
        public void Should_cascade_attendee()
        {
            var attendee = new Attendee("Joe", "Schmoe");
            var newEvent = new Conference("Some event");

            attendee.RegisterFor(newEvent);

            SaveEntities(newEvent);

            var loaded = SessionSource.CreateSession().Load<Conference>(newEvent.Id);

            loaded.GetAttendees().Count().ShouldEqual(1);
            loaded.GetAttendees().ElementAt(0).Conference.ShouldEqual(loaded);
        }
コード例 #5
0
        public ActionResult Register(AttendeeEditModel model)
        {
            if (ModelState.IsValid)
            {
                var entity   = _repository.GetById(model.ConferenceId);
                var attendee = new Attendee(model.FirstName, model.LastName)
                {
                    Email = model.Email
                };
                attendee.RegisterFor(entity);
                return(RedirectToAction("AttendeeConfirmation", model));
            }

            return(View(model));
        }