public void Should_Success_Joining_ToMetup()
        {
            var meetup = new Meetup(
                organizerId: "123",
                subject: "DDD",
                when: DateTime.Now.AddDays(1),
                description: "DDD Practices",
                location: new Location("YTÜ Teknopark"),
                policy: meetupPolicy);

            meetup.Join(Guid.NewGuid().ToString());

            Assert.Single(meetup.Participants);
        }
        public void Should_Sucess_When_AddingComment()
        {
            var meetup = new Meetup(
                organizerId: "123",
                subject: "DDD",
                when: DateTime.Now.AddDays(1),
                description: "DDD Practices",
                location: new Location("YTÜ Teknopark"),
                policy: meetupPolicy);

            meetup.Join("456");

            meetup.Complete();

            meetup.AddComment("456", "Good!");

            Assert.Single(meetup.Comments);
        }
        public void Should_ThrowException_When_Joining_ToCompletedMeetup()
        {
            var exception = Assert.Throws <MeetupDomainException>(() =>
            {
                var meetup = new Meetup(
                    organizerId: "123",
                    subject: "DDD",
                    when: DateTime.Now.AddDays(1),
                    description: "DDD Practices",
                    location: new Location("YTÜ Teknopark"),
                    policy: meetupPolicy);

                meetup.Complete();

                meetup.Join(Guid.NewGuid().ToString());
            });

            Assert.Equal("Meetup is completed", exception.Message);
        }
Example #4
0
        public async Task Should_Sucess_When_AddingComment()
        {
            var mockIdentityService = new Mock <IIdentityService>();

            mockIdentityService.Setup((x) => x.GetUserId()).Returns("456");

            var mockMeetupPolicy = new Mock <IMeetupPolicy>();

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

            var meetup = new Meetup(
                organizerId: "123",
                subject: "DDD",
                when: DateTime.Now.AddDays(1),
                description: "DDD Practices",
                location: new Location("YTÜ Teknopark"),
                policy: mockMeetupPolicy.Object);

            meetup.Join("456");
            meetup.Complete();

            _fixture.dbContext.Add(meetup);

            var meetupRepository = new MeetupRepository(_fixture.dbContext);

            var addMeetupCommentCommandHandler = new AddCommentCommandHandler(meetupRepository, mockIdentityService.Object);
            var cancellationToken = new CancellationToken();

            var addMeetupCommentCommand = new AddCommentCommand
            {
                MeetupId = meetup.Id,
                Comment  = "Good!"
            };

            await addMeetupCommentCommandHandler.Handle(addMeetupCommentCommand, cancellationToken);

            Assert.Single(_fixture.dbContext.Meetups.FirstOrDefault().Comments);
        }