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; }
public CreateMeetupCommandHandler(IAggregateRepository aggregateRepository, IMeetupPolicy meetupPolicy) { _aggregateRepository = aggregateRepository; _meetupPolicy = meetupPolicy; }
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 }); }
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)); }