public async Task Should_ThrowException_When_CreatingMeetup_If_HasMeetupInToday() { var meetupRepository = new MeetupRepository(_fixture.dbContext); var meetupPolicy = new MeetupPolicy(meetupRepository); var mockIdentityService = new Mock <IIdentityService>(); mockIdentityService.Setup((x) => x.GetUserId()).Returns("123"); var createMeetupCommandHandler = new CreateMeetupCommandHandler(meetupRepository, meetupPolicy, mockIdentityService.Object); var cancellationToken = new CancellationToken(); var createMeetupCommand = new CreateMeetupCommand { Subject = "DDD", Description = "DDD Practices", When = DateTime.Now.AddDays(5), Address = "YTÜ Teknopark" }; var exception = await Assert.ThrowsAsync <MeetupDomainException>(async() => { await createMeetupCommandHandler.Handle(createMeetupCommand, cancellationToken); }); Assert.Equal("A maximum of one meetup is defined", exception.Message); }
public async Task Should_Succes_When_CreatingMeetup() { var meetupRepository = new MeetupRepository(_fixture.dbContext); var meetupPolicy = new MeetupPolicy(meetupRepository); var mockIdentityService = new Mock <IIdentityService>(); mockIdentityService.Setup((x) => x.GetUserId()).Returns("123"); var createMeetupCommandHandler = new CreateMeetupCommandHandler(meetupRepository, meetupPolicy, mockIdentityService.Object); var cancellationToken = new CancellationToken(); var createMeetupCommand = new CreateMeetupCommand { Subject = "DDD", Description = "DDD Practices", When = DateTime.Now.AddDays(5), Address = "YTÜ Teknopark" }; await createMeetupCommandHandler.Handle(createMeetupCommand, cancellationToken); Assert.Equal(1, _fixture.dbContext.Meetups.Count()); Assert.True(_fixture.IsVerifiedMeetupAnnouncedDomainEventHandler); _fixture.IsVerifiedMeetupAnnouncedDomainEventHandler = false; }