예제 #1
0
        public MockServer(ServerSetup setup)
            : base(setup)
        {
            _serverData = MockServerData.GetInstance();

            _serverData.Domains.Clear();
            _serverData.Mailboxes.Clear();
            _serverData.Groups.Clear();

            _domainDal      = new WebDomainDal(setup.Tenant);
            _mailboxDal     = new MailboxDal(setup.Tenant, SetupInfo.Limits.MailboxMaxCountPerUser);
            _mailgroupDal   = new MailGroupDal(setup.Tenant);
            _mailaddressDal = new MailAddressDal(setup.Tenant);

            var domains = _domainDal.GetTenantDomains();

            foreach (var domain in domains)
            {
                _serverData.Domains.Add(new WebDomainBase(domain.name));
            }

            var mailboxesDto = _mailboxDal.GetMailboxes();

            foreach (var mailboxDto in mailboxesDto)
            {
                var aliasList =
                    _mailaddressDal.GetMailboxAliases(mailboxDto.mailbox.id)
                    .Select(
                        aliasDto =>
                        new MailAddressBase(aliasDto.name, new WebDomainBase(aliasDto.domain.name)))
                    .ToList();

                var resultMailbox = new MailboxBase(
                    new MailAccountBase(mailboxDto.mailbox.address),
                    //Its not login. It adress. Needed only for testing
                    new MailAddressBase(mailboxDto.mailbox_address.name,
                                        new WebDomainBase(mailboxDto.mailbox_address.domain.name)), aliasList);

                _serverData.Mailboxes.Add(resultMailbox);
            }

            var groupsDto = _mailgroupDal.GetMailGroups();

            foreach (var resultGroup in from groupDto in groupsDto
                     let groupAddresses = groupDto.addresses.Select(address =>
                                                                    new MailAddressBase(address.name,
                                                                                        new WebDomainBase
                                                                                        (
                                                                                            address
                                                                                            .domain
                                                                                            .name)))
                                          .ToList()
                                          select new MailGroupBase(
                         new MailAddressBase(groupDto.address.name,
                                             new WebDomainBase(groupDto.address.domain.name)),
                         groupAddresses))
            {
                _serverData.Groups.Add(resultGroup);
            }
        }
예제 #2
0
 public MockMailGroup(int id, int tenant, IMailAddress address, List <IMailAddress> inAddresses, MailServerBase server)
     : base(id, tenant, address, inAddresses, server)
 {
     _serverData = MockServerData.GetInstance();
 }
예제 #3
0
 public MockMailbox(int id, int tenant, IMailAddress address, IMailAccount account,
                    List <IMailAddress> aliases, MailServerBase server)
     : base(id, tenant, address, account, aliases, server)
 {
     _serverData = MockServerData.GetInstance();
 }