public async Task PublishDomainEventFromRabbitMq() { CourseCreatedDomainEvent domainEvent = CourseCreatedDomainEventMother.Random(); await _bus.Publish(new List <DomainEvent>() { domainEvent }); await _consumer.Consume(); Eventually(() => Assert.True(_subscriber.HasBeenExecuted)); }
public void create_a_valid_course() { var command = CreateCourseCommandMother.Random(); var course = CourseMother.FromRequest(command); var domainEvent = CourseCreatedDomainEventMother.FromCourse(course); this._handler.Handle(command); this.ShouldHaveSave(course); this.ShouldHavePublished(domainEvent); }
public void it_should_not_increment_an_already_incremented_course() { var domainEvent = CourseCreatedDomainEventMother.Random(); var courseId = CourseIdMother.Create(domainEvent.AggregateId); var existingCounter = CoursesCounterMother.WithOne(courseId); ShouldSearch(existingCounter); Subscriber.On(domainEvent); }
public void PublishAndConsumeDomainEventFromMsSql() { var bus = GetService <MsSqlEventBus>(); var consumer = GetService <MsSqlDomainEventsConsumer>(); var domainEvent = CourseCreatedDomainEventMother.Random(); bus.Publish(new List <DomainEvent> { domainEvent }); consumer.Consume(); }
public void create_a_valid_course() { var request = CreateCourseRequestMother.Random(); var course = CourseMother.FromRequest(request); var domainEvent = CourseCreatedDomainEventMother.FromCourse(course); this._creator.Invoke(request); this.ShouldHaveSave(course); this.ShouldHavePublished(domainEvent); }
public void it_should_increment_an_existing_counter() { var domainEvent = CourseCreatedDomainEventMother.Random(); var courseId = CourseIdMother.Create(domainEvent.AggregateId); var existingCounter = CoursesCounterMother.Random(); var incrementedCounter = CoursesCounterMother.Incrementing(existingCounter, courseId); ShouldSearch(existingCounter); Subscriber.On(domainEvent); ShouldHaveSaved(incrementedCounter); }
public void it_should_initialize_a_new_counter() { var domainEvent = CourseCreatedDomainEventMother.Random(); var courseId = CourseIdMother.Create(domainEvent.AggregateId); var newCounter = CoursesCounterMother.WithOne(courseId); ShouldSearch(); ShouldGenerateUuid(newCounter.Id.Value); Subscriber.On(domainEvent); ShouldHaveSaved(newCounter); }