Ejemplo n.º 1
0
        public void GetTest()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                string[] names = new string[] { BuildSMTPDomainName(1, 1), BuildSMTPDomainName(2, 1), BuildSMTPDomainName(3, 1) };
                //----------------------------------------------------------------------------------------------------
                //---Expected that preference is 1 on all of these, so 3 should be returned
                MX[] actual = mgr.Get(db, names, 1).ToArray();
                Assert.Equal(names.Length, actual.Length);

                //----------------------------------------------------------------------------------------------------
                //---populate array with one that has a pref of 2
                names = new string[] { BuildSMTPDomainName(1, 2), BuildSMTPDomainName(2, 1), BuildSMTPDomainName(3, 1) };

                //----------------------------------------------------------------------------------------------------
                //---null pref should still yield 3 results
                actual = mgr.Get(db, names, null).ToArray();
                Assert.Equal(3, actual.Length);

                //----------------------------------------------------------------------------------------------------
                //---should yield 2 results with pref of 1
                actual = mgr.Get(db, names, 1).ToArray();
                Assert.Equal(2, actual.Length);

                //----------------------------------------------------------------------------------------------------
                //---should yield 1 results with pref of 2
                actual = mgr.Get(db, names, 2).ToArray();
                Assert.Equal(1, actual.Length);
            }
        }
Ejemplo n.º 2
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.º 3
0
        public void GetTest3First()
        {
            InitMXRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            MX[] mxs = mgr.Get(String.Empty, MAXDOMAINCOUNT * MAXSMTPCOUNT);

            //----------------------------------------------------------------------------------------------------
            //---expected that all of the records will be returned
            Assert.Equal(MAXSMTPCOUNT * MAXDOMAINCOUNT, mxs.Length);

            //----------------------------------------------------------------------------------------------------
            //---try one with a limited number less than max count
            mxs = mgr.Get(String.Empty, 3);
            Assert.Equal(3, mxs.Length);
        }
Ejemplo n.º 4
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.º 5
0
        public void RemoveTest()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            //----------------------------------------------------------------------------------------------------
            //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)
            string name = BuildSMTPDomainName(1, 1);
            MX     obj  = mgr.Get(name);

            Assert.NotNull(obj);
            mgr.Remove(name);
            obj = mgr.Get(name);
            Assert.Null(obj);
        }
Ejemplo n.º 6
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.º 7
0
        public void GetTest2Last()
        {
            InitMXRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));


            //----------------------------------------------------------------------------------------------------
            //---get the full dictionary using the smtp domain name as the key and pick one to start at
            Dictionary <string, MX> mxsAll = mgr.ToDictionary(p => p.SMTPDomainName);

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, mxsAll.Count);

            //----------------------------------------------------------------------------------------------------
            //---grab the key at position 5 in the array, and use that as the "last" name to be passed in
            string val = mxsAll.Keys.ToArray()[4];

            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MX[] mxs = mgr.Get(db, val, MAXDOMAINCOUNT * MAXSMTPCOUNT).ToArray();

                //----------------------------------------------------------------------------------------------------
                //---expected that the count of mxs will be  max count - 5
                Assert.Equal(MAXSMTPCOUNT * MAXDOMAINCOUNT - 5, mxs.Length);

                //----------------------------------------------------------------------------------------------------
                //---try one with a limited number less than max count
                mxs = mgr.Get(db, val, 3).ToArray();
                Assert.Equal(3, mxs.Length);

                //----------------------------------------------------------------------------------------------------
                //---get the last item and see to ensure that no records are returned
                val = mxsAll.Keys.ToArray().Last();
                mxs = mgr.Get(db, val, MAXDOMAINCOUNT * MAXSMTPCOUNT).ToArray();
                Assert.Equal(0, mxs.Length);

                //----------------------------------------------------------------------------------------------------
                //---get the first item and see to ensure that MAX - 1 records are returned
                val = mxsAll.Keys.ToArray().First();
                mxs = mgr.Get(db, val, MAXDOMAINCOUNT * MAXSMTPCOUNT).ToArray();

                Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT - 1, mxs.Length);
            }
        }
Ejemplo n.º 8
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.º 9
0
        public void UpdateTest()
        {
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            InitMXRecords();
            //----------------------------------------------------------------------------------------------------
            //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)
            MX obj = mgr.Get(BuildSMTPDomainName(1, 1));

            Assert.NotNull(obj);
            //----------------------------------------------------------------------------------------------------
            //---since we set pref to the same as the smtp[x].domain[y].test.com x value, check it here
            Assert.Equal(1, obj.Preference);
            obj.Preference = 4;
            mgr.Update(obj);
        }
Ejemplo n.º 10
0
        public void GetTest5()
        {
            InitMXRecords();
            MXManager mgr      = new MXManager(new ConfigStore(CONNSTR));
            string    name     = BuildSMTPDomainName(1, 1);
            MX        mxActual = mgr.Get(name);

            Assert.NotNull(mxActual);
            //----------------------------------------------------------------------------------------------------
            //---check basic values
            Assert.Equal(name, mxActual.SMTPDomainName);
            Assert.Equal(1, mxActual.DomainID);
            //----------------------------------------------------------------------------------------------------
            //---preference should always be the same as smtp id used to create the name
            Assert.Equal(1, mxActual.Preference);
        }
Ejemplo n.º 11
0
        public void RemoveTest()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
           
            //----------------------------------------------------------------------------------------------------
            //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)
            string name = BuildSMTPDomainName(1, 1);
            MX obj = mgr.Get(name);
            Assert.NotNull(obj);
            mgr.Remove(name);
            obj = mgr.Get(name);
            Assert.Null(obj);
           
        }
Ejemplo n.º 12
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.º 13
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.º 14
0
        public void GetTest4()
        {
            InitMXRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            string name = BuildSMTPDomainName(1, 1);
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MX mxActual = mgr.Get(db, name);

                //----------------------------------------------------------------------------------------------------
                //---check basic values
                Assert.Equal(name, mxActual.SMTPDomainName);
                Assert.Equal(1, mxActual.DomainID);
                //----------------------------------------------------------------------------------------------------
                //---preference should always be the same as smtp id used to create the name
                Assert.Equal(1, mxActual.Preference);
            }
            
        }
Ejemplo n.º 15
0
        public void GetTest2Last()
        {
            InitMXRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            

            //----------------------------------------------------------------------------------------------------
            //---get the full dictionary using the smtp domain name as the key and pick one to start at
            Dictionary<string, MX> mxsAll = mgr.ToDictionary(p => p.SMTPDomainName);

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, mxsAll.Count);

            //----------------------------------------------------------------------------------------------------
            //---grab the key at position 5 in the array, and use that as the "last" name to be passed in
            string val = mxsAll.Keys.ToArray()[4];
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MX[] mxs = mgr.Get(db, val, MAXDOMAINCOUNT * MAXSMTPCOUNT).ToArray();

                //----------------------------------------------------------------------------------------------------
                //---expected that the count of mxs will be  max count - 5
                Assert.Equal(MAXSMTPCOUNT * MAXDOMAINCOUNT - 5, mxs.Length);

                //----------------------------------------------------------------------------------------------------
                //---try one with a limited number less than max count
                mxs = mgr.Get(db, val, 3).ToArray();
                Assert.Equal(3, mxs.Length);

                //----------------------------------------------------------------------------------------------------
                //---get the last item and see to ensure that no records are returned
                val = mxsAll.Keys.ToArray().Last();
                mxs = mgr.Get(db, val, MAXDOMAINCOUNT * MAXSMTPCOUNT).ToArray();
                Assert.Equal(0, mxs.Length);

                //----------------------------------------------------------------------------------------------------
                //---get the first item and see to ensure that MAX - 1 records are returned
                val = mxsAll.Keys.ToArray().First();
                mxs = mgr.Get(db, val, MAXDOMAINCOUNT * MAXSMTPCOUNT).ToArray();

                Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT - 1, mxs.Length);
            }
            
        }
Ejemplo n.º 16
0
        public void GetTest2First()
        {
            InitMXRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MX[] mxs = mgr.Get(db, String.Empty, MAXDOMAINCOUNT * MAXSMTPCOUNT).ToArray();

                //----------------------------------------------------------------------------------------------------
                //---expected that all of the records will be returned
                Assert.Equal(MAXSMTPCOUNT * MAXDOMAINCOUNT, mxs.Length);

                //----------------------------------------------------------------------------------------------------
                //---try one with a limited number less than max count
                mxs = mgr.Get(db, String.Empty, 3).ToArray();

                Assert.Equal(3, mxs.Length);
            }
        }
Ejemplo n.º 17
0
        public void GetTest()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {

                string[] names = new string[] { BuildSMTPDomainName(1, 1), BuildSMTPDomainName(2, 1), BuildSMTPDomainName(3, 1) };
                //----------------------------------------------------------------------------------------------------
                //---Expected that preference is 1 on all of these, so 3 should be returned
                MX[] actual = mgr.Get(db, names, 1).ToArray();
                Assert.Equal(names.Length, actual.Length);

                //----------------------------------------------------------------------------------------------------
                //---populate array with one that has a pref of 2
                names = new string[] { BuildSMTPDomainName(1, 2), BuildSMTPDomainName(2, 1), BuildSMTPDomainName(3, 1) };

                //----------------------------------------------------------------------------------------------------
                //---null pref should still yield 3 results
                actual = mgr.Get(db, names, null).ToArray();
                Assert.Equal(3, actual.Length);

                //----------------------------------------------------------------------------------------------------
                //---should yield 2 results with pref of 1
                actual = mgr.Get(db, names, 1).ToArray();
                Assert.Equal(2, actual.Length);

                //----------------------------------------------------------------------------------------------------
                //---should yield 1 results with pref of 2
                actual = mgr.Get(db, names, 2).ToArray();
                Assert.Equal(1, actual.Length);
            }
            
        }
Ejemplo n.º 18
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.º 19
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.º 20
0
 public void UpdateTest()
 {
     MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
     InitMXRecords();
     //----------------------------------------------------------------------------------------------------
     //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)
     MX obj = mgr.Get(BuildSMTPDomainName(1,1));
     Assert.NotNull(obj);
     //----------------------------------------------------------------------------------------------------
     //---since we set pref to the same as the smtp[x].domain[y].test.com x value, check it here
     Assert.Equal(1, obj.Preference);
     obj.Preference = 4;
     mgr.Update(obj);
 }