示例#1
0
        public void DoormanInitializesSemaphoreSlim()
        {
            var doorman = new Doorman();

            Assert.NotNull(doorman.Semaphore);
            Assert.Equal(1, doorman.Semaphore.CurrentCount);
        }
示例#2
0
        private void ActionGmail(string[] accountDetail)
        {
            Doorman.Wait();
            Gmail gmail;

            if (accountDetail.Length == 2)
            {
                gmail = new Gmail(accountDetail[0], accountDetail[1]);
            }
            else if (accountDetail.Length == 4)
            {
                gmail = new Gmail(accountDetail[0], accountDetail[1], accountDetail[2], accountDetail[3]);
            }
            else
            {
                Doorman.Release();
                return;
            }
            bool init = gmail.Init();

            if (!init)
            {
                Doorman.Release();
                return;
            }
            gmail.Connect();

            if (open.Checked)
            {
                while (!gmail.CheckIfClosed())
                {
                    Thread.Sleep(5000);
                }
                Doorman.Release();
                return;
            }

            if (gmail.CheckIfConnected())
            {
                gmail.OldGmail();
                //to spam action
                if (Check_gmail_spam_checked())
                {
                    SpamGmail(gmail);
                }

                //to inbox action()
                if (Check_yahoo_inbox_checked())
                {
                    InboxGmail(gmail);
                }

                gmail.Destroy();
            }
            Doorman.Release();
        }
        public void RentingGivesDifferentInstances()
        {
            Doorman first  = DoormanPool.Rent();
            Doorman second = DoormanPool.Rent();

            Assert.NotSame(first, second);

            DoormanPool.Return(first);
            DoormanPool.Return(second);
        }
示例#4
0
        private void Delete_emails(string[] accountDetail)
        {
            Doorman.Wait();
            Yahoo yahoo;

            if (accountDetail.Length == 2)
            {
                yahoo = new Yahoo(accountDetail[0], accountDetail[1]);
            }
            else if (accountDetail.Length == 4)
            {
                yahoo = new Yahoo(accountDetail[0], accountDetail[1], accountDetail[2], accountDetail[3]);
            }
            else
            {
                Doorman.Release();
                return;
            }

            yahoo.Init();
            yahoo.Connect();

            if (yahoo.CheckIfConnected())
            {
                yahoo.Navigate("https://mail.yahoo.com/neo/b/launch");

                if (checkbox_spam_yahoo.Checked)
                {
                    yahoo.DeleteSpam();
                }

                if (checkbox_inbox_yahoo.Checked)
                {
                    //all magic happen here
                    bool repeat_delete_inbox()
                    {
                        if (yahoo.DeleteInbox())
                        {
                            return(yahoo.DeleteInbox());
                        }
                        return(false);
                    }

                    while (repeat_delete_inbox())
                    {
                        Application.DoEvents();
                    }
                    new Logger().Info("All inbox email deleted : " + accountDetail[0]);
                }
            }

            yahoo.Destroy();
            Doorman.Release();
        }
示例#5
0
        public void DoormanResetsRefCounter()
        {
            var doorman = new Doorman();

            Assert.Equal(1, doorman.RefCount);
            doorman.RefCount--;

            Assert.Equal(0, doorman.RefCount);

            doorman.Reset();
            Assert.Equal(1, doorman.RefCount);
        }
        public void DoormanPoolReusesItems()
        {
            Doorman first = DoormanPool.Rent();

            DoormanPool.Return(first);

            Doorman second = DoormanPool.Rent();

            Assert.Equal(first, second);

            DoormanPool.Return(second);
        }
示例#7
0
        public void DoormanPoolReusesItems()
        {
            int     initialCount = DoormanPool.Count();
            Doorman first        = DoormanPool.Rent();

            int currentCount = DoormanPool.Count();

            if (currentCount > 0)
            {
                Assert.Equal(initialCount - 1, currentCount);
                DoormanPool.Return(first);
                Assert.Equal(initialCount, DoormanPool.Count());
            }
            else
            {
                Assert.Equal(0, currentCount);
                DoormanPool.Return(first);
                Assert.Equal(initialCount + 1, DoormanPool.Count());
            }
        }
示例#8
0
        private void Delete_emails_gmail(string[] accountDetail)
        {
            Doorman.Wait();
            Gmail gmail;

            if (accountDetail.Length == 2)
            {
                gmail = new Gmail(accountDetail[0], accountDetail[1]);
            }
            else if (accountDetail.Length == 4)
            {
                gmail = new Gmail(accountDetail[0], accountDetail[1], accountDetail[2], accountDetail[3]);
            }
            else
            {
                Doorman.Release();
                return;
            }

            gmail.Init();
            gmail.Connect();
            gmail.OldGmail();

            if (delete_gmail_spam.Checked)
            {
                bool repeat_delete_spam()
                {
                    if (gmail.DeleteSpam())
                    {
                        return(gmail.DeleteSpam());
                    }
                    return(false);
                }

                while (repeat_delete_spam())
                {
                    Application.DoEvents();
                }
                new Logger().Info("All Spam email deleted : " + accountDetail[0]);
            }

            if (delete_gmail_inbox.Checked)
            {
                bool repeat_delete_inbox()
                {
                    if (gmail.DeleteInbox())
                    {
                        return(gmail.DeleteInbox());
                    }
                    return(false);
                }

                while (repeat_delete_inbox())
                {
                    Application.DoEvents();
                }
                new Logger().Info("All inbox email deleted : " + accountDetail[0]);
            }

            gmail.Destroy();
            Doorman.Release();
        }
示例#9
0
        private void ActionYahoo(string[] accountDetail)
        {
            Doorman.Wait();
            Yahoo yahoo;

            if (accountDetail.Length == 2)
            {
                yahoo = new Yahoo(accountDetail[0], accountDetail[1]);
            }
            else if (accountDetail.Length == 4)
            {
                yahoo = new Yahoo(accountDetail[0], accountDetail[1], accountDetail[2], accountDetail[3]);
            }
            else
            {
                Doorman.Release();
                return;
            }
            bool error = yahoo.Init();

            if (!error)
            {
                MessageBox.Show("ERROR INIT", "Error");
                Doorman.Release();
                return;
            }

            if (open.Checked)
            {
                yahoo.Connect();
                yahoo.Navigate("https://mail.yahoo.com/");

                while (!yahoo.CheckIfClosed())
                {
                    Thread.Sleep(5000);
                }
                Doorman.Release();
                return;
            }

            yahoo.Connect();

            if (yahoo.CheckIfConnected())
            {
                yahoo.Navigate("https://mail.yahoo.com/neo/b/launch");

                //to spam action
                if (Check_yahoo_spam_checked())
                {
                    SpamYahoo(yahoo);
                }

                //to inbox action()
                if (Check_yahoo_inbox_checked())
                {
                    InboxYahoo(yahoo);
                }

                yahoo.Destroy();
            }
            Doorman.Release();
        }