Beispiel #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);
        }
Beispiel #2
0
        public void GetEnumeratorTest1()
        {
            InitMXRecords();
            IEnumerable <MX> mgr = new MXManager(new ConfigStore(CONNSTR));

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, mgr.Count());
        }
Beispiel #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));
            }
        }
Beispiel #4
0
        public void CountTest()
        {
            InitMXRecords();

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

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, actual);
        }
Beispiel #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);
        }
Beispiel #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());
            }
        }
Beispiel #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);
            
        }
Beispiel #8
0
        public void CountTest()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            int actual = mgr.Count();
            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, actual);
            
        }
Beispiel #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());
     }
 }
Beispiel #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);
     
 }
Beispiel #11
0
 public void GetEnumeratorTest1()
 {
     InitMXRecords();
     IEnumerable<MX> mgr = new MXManager(new ConfigStore(CONNSTR));
     Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, mgr.Count());
 }
Beispiel #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));
            }
            
        }