Esempio n. 1
0
 public void Setup()
 {
     _invitationRepository  = new Mock <IInvitationRepository>();
     _membershipRepository  = new Mock <IMembershipRepository>();
     _userAccountRepository = new Mock <IUserAccountRepository>();
     _auditService          = new Mock <IAuditService>();
     _handler = new AcceptInvitationCommandHandler(
         _invitationRepository.Object,
         _membershipRepository.Object,
         _userAccountRepository.Object,
         _auditService.Object);
     _invitation = new Invitation
     {
         Id         = 1,
         AccountId  = 101,
         Email      = "*****@*****.**",
         Status     = InvitationStatus.Pending,
         ExpiryDate = DateTimeProvider.Current.UtcNow.AddDays(2),
         RoleId     = Role.Owner
     };
 }
Esempio n. 2
0
        public void Setup()
        {
            _invitation = new Invitation
            {
                Id         = 1,
                AccountId  = 101,
                Email      = "*****@*****.**",
                Status     = InvitationStatus.Pending,
                ExpiryDate = DateTimeProvider.Current.UtcNow.AddDays(2),
                Role       = Role.Owner,
                Name       = "Bob Green"
            };

            _invitationRepository  = new Mock <IInvitationRepository>();
            _membershipRepository  = new Mock <IMembershipRepository>();
            _userAccountRepository = new Mock <IUserAccountRepository>();
            _auditService          = new Mock <IAuditService>();
            _eventPublisher        = new TestableEventPublisher();
            _validator             = new Mock <IValidator <AcceptInvitationCommand> >();
            _hashingService        = new Mock <IHashingService>();

            _validator.Setup(x => x.Validate(It.IsAny <AcceptInvitationCommand>())).Returns(new ValidationResult());

            _membershipRepository.Setup(x => x.GetCaller(It.IsAny <long>(), It.IsAny <string>())).ReturnsAsync(() => null);

            _invitationRepository.Setup(x => x.Get(It.IsAny <long>())).ReturnsAsync(_invitation);
            _userAccountRepository.Setup(x => x.Get(It.IsAny <string>())).ReturnsAsync(new User {
                UserRef = Guid.NewGuid().ToString()
            });

            _handler = new AcceptInvitationCommandHandler(
                _invitationRepository.Object,
                _membershipRepository.Object,
                _userAccountRepository.Object,
                _auditService.Object,
                _eventPublisher,
                _validator.Object,
                _hashingService.Object,
                Mock.Of <ILog>());
        }