public void Show_methods_return_false_if_ni_is_null()
 {
     Notifier notifier = new Notifier();
     Assert.IsFalse(notifier.ShowNotification(null));
     Assert.IsFalse(notifier.ShowAuthError());
     Assert.IsFalse(notifier.ShowDefault());
 }
Пример #2
0
        /// <summary>
        /// Запускает приложение.
        /// </summary>
        /// <exception cref="System.Exception">
        /// </exception>
        public void RunApp()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            receiver = new MsgReceiver();
            notifier = new Notifier();
            brain = new Brain();
            unreadMessagesForm = new AllMessagesForm();

            if (!notifier.InitNotifier())
                throw new Exception();

            if (brain.LoadSettings())
                if(!string.IsNullOrEmpty(brain.Login))
                    receiver.LogInVk(brain.Login, brain.Password);

            if (!receiver.IsLogged())
            {
                ShowLoginWindow();

                // Случай, когда пользователь просто закрыл окно входа
                if (!receiver.IsLogged())
                {
                    notifier.ShowAuthError();

                    brain.Login = "";
                    brain.Password = "";
                }
            }
            else
                notifier.ShowDefault();

            SetupNotifyIconMenus();

            if (!notifier.SetContextMenu(contextMenu))
                throw new Exception();

            if (!notifier.SetLaunchCallback(LaunchCallback))
                throw new Exception();

            if (!brain.InitBrain(receiver, notifier, unreadMessagesForm))
                throw new Exception();

            appTimer = new System.Timers.Timer(5000);
            appTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            appTimer.Enabled = true;

            Application.ApplicationExit += AppExitEvent;
            Application.Run();
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Form1"/> class.
        /// </summary>
        /// <exception cref="System.Exception">
        /// </exception>
        public Form1()
        {
            InitializeComponent();

            this.FormClosing += Form1_FormClosing;

            receiver = new MsgReceiver();
            notifier = new Notifier();
            brain = new Brain();
            unreadMessagesForm = new AllMessagesForm();

            if (!notifier.InitNotifier())
                throw new Exception();

            if (brain.LoadSettings())
                if (!string.IsNullOrEmpty(brain.Login))
                    receiver.LogInVk(brain.Login, brain.Password);

            if (!receiver.IsLogged())
            {
                ShowLoginWindow();

                // Случай, когда пользователь просто закрыл окно входа
                if (!receiver.IsLogged())
                {
                    notifier.ShowAuthError();

                    brain.Login = "";
                    brain.Password = "";
                }
            }
            else
                notifier.ShowDefault();

            SetupNotifyIconMenus();

            if (!notifier.SetContextMenu(contextMenu))
                throw new Exception();

            if (!notifier.SetLaunchCallback(LaunchCallback))
                throw new Exception();

            if (!brain.InitBrain(receiver, notifier, unreadMessagesForm))
                throw new Exception();
        }
 public void ShowNotification_throws_exception_if_argument_is_null()
 {
     Notifier notifier = new Notifier();
     notifier.InitNotifier();
     notifier.ShowNotification(null);
 }