示例#1
0
        public async Task ShouldSendEmailWhenAccepting()
        {
            // Arrange
            var mockMediator  = new Mock <IMediator>();
            var mockUrlHelper = new Mock <IUrlHelper>();

            mockUrlHelper.Setup(x => x.Link(It.IsAny <string>(), It.IsAny <object>())).Returns(eventUrl);
            mockUrlHelper.Setup(x => x.Action(It.IsAny <UrlActionContext>())).Returns(eventUrl);
            var handler = new AcceptEventManagerInviteCommandHandler(Context, mockMediator.Object, mockUrlHelper.Object);

            handler.DateTimeUtcNow = () => { return(AcceptedTime); };

            // Act
            await handler.Handle(new AcceptEventManagerInviteCommand
            {
                EventManagerInviteId = inviteId
            });

            // Assert
            mockMediator.Verify(x => x.PublishAsync(It.Is <EventManagerInviteAccepted>(c =>
                                                                                       c.EventName == eventName &&
                                                                                       c.CampaignName == campaignName &&
                                                                                       c.EventUrl == eventUrl &&
                                                                                       c.InviteeEmail == inviteeEmail &&
                                                                                       c.SenderEmail == senderEmail
                                                                                       )), Times.Once);
        }
示例#2
0
        public async Task ShouldSetIsAcceptedToTrue()
        {
            // Arrange
            var handler = new AcceptEventManagerInviteCommandHandler(Context, Mock.Of <IMediator>(), Mock.Of <IUrlHelper>());

            handler.DateTimeUtcNow = () => { return(AcceptedTime); };

            // Act
            await handler.Handle(new AcceptEventManagerInviteCommand
            {
                EventManagerInviteId = inviteId
            });

            // Assert
            var invite = Context.EventManagerInvites.SingleOrDefault(i => i.Id == inviteId);

            invite.IsAccepted.ShouldBe(true);
            invite.AcceptedDateTimeUtc.ShouldBe(AcceptedTime);
        }