Ejemplo n.º 1
0
        public void AddTest()
        {
            //----------------------------------------------------------------------------------------------------
            //---only init the domain records which will force a cleaning of the mx records
            InitDomainRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            //----------------------------------------------------------------------------------------------------
            //---make sure there are no mx records that exist
            Assert.Equal(0, mgr.Count());

            long   domainId   = 1; //--we always have domain id of 1 (unless someone changed testing values in base)
            string SMTPName   = BuildSMTPDomainName(1, 1);
            int    preference = 10;
            MX     mx         = new MX(domainId
                                       , SMTPName
                                       , preference);

            mgr.Add(mx);
            Assert.Equal(1, mgr.Count());
            mx = mgr.Get(SMTPName);
            Assert.Equal(domainId, mx.DomainID);
            Assert.Equal(SMTPName, mx.SMTPDomainName);
            Assert.Equal(preference, mx.Preference);
        }
Ejemplo n.º 2
0
        public void GetEnumeratorTest1()
        {
            InitMXRecords();
            IEnumerable <MX> mgr = new MXManager(new ConfigStore(CONNSTR));

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, mgr.Count());
        }
Ejemplo n.º 3
0
        public void RemoveDomainTest()
        {
            InitMXRecords();
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

                //----------------------------------------------------------------------------------------------------
                //---make sure that the domains are actually there
                for (int t = 1; t <= MAXSMTPCOUNT; t++)
                {
                    string name = BuildSMTPDomainName(1, t);
                    MX     obj  = mgr.Get(db, name);
                    Assert.NotNull(obj);
                }

                //----------------------------------------------------------------------------------------------------
                //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)

                mgr.RemoveDomain(db, 1);
                //----------------------------------------------------------------------------------------------------
                //---there should be no items left with domain id of 1, use the count to check number of matching
                //---per domain as well as a loop to ensure that each entry has been removed for the given domain
                for (int t = 1; t <= MAXSMTPCOUNT; t++)
                {
                    string name = BuildSMTPDomainName(1, t);
                    MX     obj  = mgr.Get(db, name);
                    Assert.Null(obj);
                }
                Assert.Equal(0, mgr.Count(1));
            }
        }
Ejemplo n.º 4
0
        public void CountTest()
        {
            InitMXRecords();

            MXManager mgr    = new MXManager(new ConfigStore(CONNSTR));
            int       actual = mgr.Count();

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, actual);
        }
Ejemplo n.º 5
0
        public void GetTest7()
        {
            InitMXRecords();
            MXManager     mgr = new MXManager(new ConfigStore(CONNSTR));
            List <string> lst = AllMXDomainNames();

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, lst.Count());
            MX[] mxs = mgr.Get(lst.ToArray());
            Assert.Equal(mgr.Count(), mxs.Length);
        }
Ejemplo n.º 6
0
        public void GetTest6()
        {
            InitMXRecords();
            MXManager     mgr = new MXManager(new ConfigStore(CONNSTR));
            List <string> lst = AllMXDomainNames();

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, lst.Count());
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                IEnumerable <MX> mxs = mgr.Get(db, lst.ToArray());

                Assert.Equal(mgr.Count(), mxs.Count());
            }
        }
Ejemplo n.º 7
0
        public void AddTest()
        {
            //----------------------------------------------------------------------------------------------------
            //---only init the domain records which will force a cleaning of the mx records
            InitDomainRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            //----------------------------------------------------------------------------------------------------
            //---make sure there are no mx records that exist
            Assert.Equal(0, mgr.Count());

            long domainId = 1; //--we always have domain id of 1 (unless someone changed testing values in base)
            string SMTPName = BuildSMTPDomainName(1, 1);
            int preference = 10;
            MX mx = new MX(domainId
                           , SMTPName
                           , preference);

            mgr.Add(mx);
            Assert.Equal(1, mgr.Count());
            mx = mgr.Get(SMTPName);
            Assert.Equal(domainId, mx.DomainID);
            Assert.Equal(SMTPName, mx.SMTPDomainName);
            Assert.Equal(preference, mx.Preference);
            
        }
Ejemplo n.º 8
0
        public void CountTest()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            int actual = mgr.Count();
            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, actual);
            
        }
Ejemplo n.º 9
0
 public void GetTest6()
 {
     InitMXRecords();
     MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
     List<string> lst = AllMXDomainNames();
     Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, lst.Count());
     using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
     {
         IEnumerable<MX> mxs = mgr.Get(db, lst.ToArray());
     
         Assert.Equal(mgr.Count(), mxs.Count());
     }
 }
Ejemplo n.º 10
0
 public void GetTest7()
 {
     InitMXRecords();
     MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
     List<string> lst = AllMXDomainNames();
     Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, lst.Count());
     MX[] mxs = mgr.Get(lst.ToArray());
     Assert.Equal(mgr.Count(), mxs.Length);
     
 }
Ejemplo n.º 11
0
 public void GetEnumeratorTest1()
 {
     InitMXRecords();
     IEnumerable<MX> mgr = new MXManager(new ConfigStore(CONNSTR));
     Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, mgr.Count());
 }
Ejemplo n.º 12
0
        public void RemoveDomainTest()
        {
            InitMXRecords();
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

                //----------------------------------------------------------------------------------------------------
                //---make sure that the domains are actually there
                for (int t = 1; t <= MAXSMTPCOUNT; t++)
                {
                    string name = BuildSMTPDomainName(1, t);
                    MX obj = mgr.Get(db, name);
                    Assert.NotNull(obj);
                }

                //----------------------------------------------------------------------------------------------------
                //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)

                mgr.RemoveDomain(db, 1);
                //----------------------------------------------------------------------------------------------------
                //---there should be no items left with domain id of 1, use the count to check number of matching
                //---per domain as well as a loop to ensure that each entry has been removed for the given domain
                for (int t = 1; t <= MAXSMTPCOUNT; t++)
                {
                    string name = BuildSMTPDomainName(1, t);
                    MX obj = mgr.Get(db, name);
                    Assert.Null(obj);
                }
                Assert.Equal(0, mgr.Count(1));
            }
            
        }