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

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, mgr.Count());
        }
Beispiel #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);
        }
Beispiel #5
0
 public void StoreTest()
 {
     ConfigStore store = new ConfigStore(CONNSTR);
     MXManager target = new MXManager(store); // TODO: Initialize to an appropriate value
     ConfigStore actual = target.Store;
     Assert.Equal(target.Store, actual);
     
 }
Beispiel #6
0
        public void StoreTest()
        {
            ConfigStore store  = new ConfigStore(CONNSTR);
            MXManager   target = new MXManager(store); // TODO: Initialize to an appropriate value
            ConfigStore actual = target.Store;

            Assert.Equal(target.Store, actual);
        }
Beispiel #7
0
        public void CountTest()
        {
            InitMXRecords();

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

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, actual);
        }
Beispiel #8
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 #9
0
        public void GetEnumeratorTest()
        {
            InitMXRecords();
            MXManager        mgr    = new MXManager(new ConfigStore(CONNSTR));
            IEnumerator <MX> actual = mgr.GetEnumerator();
            int cnt = 0;

            while (actual.MoveNext())
            {
                cnt++;
            }

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, cnt);
        }
Beispiel #10
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 #11
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);
        }
Beispiel #12
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);
        }
Beispiel #13
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);
        }
Beispiel #14
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);
        }
Beispiel #15
0
        public void RemoveTest1()
        {
            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);

            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MX obj = db.MXs.Get(name);
                Assert.NotNull(obj);
                mgr.Remove(db, name);
                db.SubmitChanges();
                obj = db.MXs.Get(name);
                Assert.Null(obj);
            }
        }
Beispiel #16
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);
            }
        }
Beispiel #17
0
        public void RemoveTest1()
        {
            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);

            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MX obj = db.MXs.Get(name);
                Assert.NotNull(obj);
                mgr.Remove(db, name);
                db.SubmitChanges();
                obj = db.MXs.Get(name);
                Assert.Null(obj);
            }
            
            
        }
Beispiel #18
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 #19
0
 public void GetEnumeratorTest1()
 {
     InitMXRecords();
     IEnumerable<MX> mgr = new MXManager(new ConfigStore(CONNSTR));
     Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, mgr.Count());
 }
Beispiel #20
0
        public void GetEnumeratorTest()
        {
            InitMXRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            IEnumerator<MX> actual = mgr.GetEnumerator();
            int cnt = 0;
            while(actual.MoveNext()){
                cnt++;
            }

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, cnt);
            
        }
Beispiel #21
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 #22
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);
            }
            
        }
Beispiel #23
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 #24
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);
            }
        }
Beispiel #25
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);
            }
            
        }
Beispiel #26
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);
            }
            
        }
Beispiel #27
0
        public void CountTest()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            int actual = mgr.Count();
            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, actual);
            
        }
Beispiel #28
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 #29
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);
 }
Beispiel #30
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);
           
        }