public CreateMeetupCommandHandler(
     IMeetupRepository meetupRepository,
     IMeetupPolicy meetupPolicy,
     IIdentityService identityService)
 {
     _meetupRepository = meetupRepository;
     _meetupPolicy     = meetupPolicy;
     _identityService  = identityService;
 }
        public MeetupAggregateTests()
        {
            var mockMeetupPolicy = new Mock <IMeetupPolicy>();

            mockMeetupPolicy.Setup((x) => x.CheckCanDefineMeetup(It.IsAny <string>(), It.IsAny <DateTime>())).Callback(() => { });

            meetupPolicy = mockMeetupPolicy.Object;

            var mockMeetupPolicy1 = new Mock <IMeetupPolicy>();

            mockMeetupPolicy1.Setup((x) => x.CheckCanDefineMeetup(It.IsAny <string>(), It.IsAny <DateTime>())).Callback(() =>
            {
                throw new MeetupDomainException("A maximum of one meetup is defined");
            });

            meetupPolicy1 = mockMeetupPolicy1.Object;
        }
예제 #3
0
 public CreateMeetupCommandHandler(IAggregateRepository aggregateRepository, IMeetupPolicy meetupPolicy)
 {
     _aggregateRepository = aggregateRepository;
     _meetupPolicy        = meetupPolicy;
 }
예제 #4
0
        public async Task Register(MeetupId meetupId, OrganizerId organizerId, Subject subject, When when, Description description, Address address, IMeetupPolicy policy)
        {
            if (Version >= 0)
            {
                throw new MeetupAlreadyRegisteredException();
            }

            await policy.CheckCanDefineMeetupAsync(organizerId, when);

            ApplyEvent(new MeetupRegistered
            {
                MeetupId    = meetupId,
                OrganizerId = organizerId,
                Subject     = subject,
                When        = when,
                Description = description,
                Address     = address,
                CreatedDate = DateTime.Now
            });
        }
예제 #5
0
        public Meetup(string organizerId, string subject, DateTime when, string description, Location location, IMeetupPolicy policy)
        {
            if (string.IsNullOrEmpty(organizerId))
            {
                throw new MeetupDomainException("Organizer is required");
            }

            if (string.IsNullOrEmpty(subject))
            {
                throw new MeetupDomainException("Subject is required");
            }

            if (when == null)
            {
                throw new MeetupDomainException("When is required");
            }

            if (when <= DateTime.Today)
            {
                throw new MeetupDomainException("When must greater than today");
            }

            if (string.IsNullOrEmpty(description))
            {
                throw new MeetupDomainException("Description is required");
            }

            if (location == null)
            {
                throw new MeetupDomainException("Location is required");
            }

            policy.CheckCanDefineMeetup(organizerId, when);

            Id          = Guid.NewGuid().ToString();
            OrganizerId = organizerId;
            Subject     = subject;
            When        = when;
            Description = description;
            Location    = location;

            AddDomainEvent(new MeetupAnnouncedDomainEvent(this));
        }