public void SetUp() { var createEmailAccountCommand = new CreateEmailAccount { SiteId = Guid.NewGuid(), Id = Guid.NewGuid(), Address = "*****@*****.**", DisplayName = "My Site", Host = "host", Port = 25, UserName = "******", Password = "******", DefaultCredentials = true, Ssl = true }; var createEmailAccountValidatorMock = new Mock <IValidator <CreateEmailAccount> >(); createEmailAccountValidatorMock.Setup(x => x.Validate(createEmailAccountCommand)).Returns(new ValidationResult()); _emailAccount = EmailAccount.CreateNew(createEmailAccountCommand, createEmailAccountValidatorMock.Object); _command = new DeleteEmailAccount { SiteId = _emailAccount.SiteId, Id = _emailAccount.Id }; _validatorMock = new Mock <IValidator <DeleteEmailAccount> >(); _validatorMock.Setup(x => x.Validate(_command)).Returns(new ValidationResult()); _emailAccount.Delete(_command, _validatorMock.Object); _event = _emailAccount.Events.OfType <EmailAccountDeleted>().SingleOrDefault(); }
public ICollection <IEvent> Handle(CreateEmailAccount command) { var emailAccount = EmailAccount.CreateNew(command, _validator); _emailAccountRepository.Create(emailAccount); return(emailAccount.Events); }
public IAggregateRoot Handle(CreateEmailAccount command) { var emailAccount = EmailAccount.CreateNew(command, _validator); _emailAccountRepository.Create(emailAccount); return(emailAccount); }