Ejemplo n.º 1
0
        public void Check_auto_update()
        {
            File.WriteAllText(Path.Combine(AccentanceSetup.Config.RtmUpdatePath, "version.txt"), "99.99.99.99");
            DbHelper.CopyBin("acceptance", AccentanceSetup.Config.RtmUpdatePath);
            DbHelper.CopyBin(DbHelper.ProjectBin("updater"), AccentanceSetup.Config.RtmUpdatePath);
            AccentanceSetup.Configure("acceptance", AccentanceSetup.Url.ToString());

            HandleDialogs();
            Activate();
            Click("Update");
            AssertUpdate("Получена новая версия программы. Сейчас будет выполнено обновление.");

            FilterByProcess = false;
            var update = Opened.Timeout(5.Second()).First();

            AssertText(update, "Внимание! Происходит обновление программы.");

            update = Opened.Where(e => e.Current.Name == "Обмен данными").Timeout(15.Second()).First();
            AssertText(update, "Производится обмен данными");
            FilterByProcess = true;
            Process         = System.Diagnostics.Process.GetProcessById(update.Current.ProcessId);
            MainWindow      = AutomationElement.RootElement.FindFirst(TreeScope.Children, new AndCondition(
                                                                          new PropertyCondition(AutomationElement.ProcessIdProperty, Process.Id),
                                                                          new PropertyCondition(AutomationElement.NameProperty, "АналитФАРМАЦИЯ - тестовый")));

            var message = Opened.Timeout(15.Second()).First();

            AssertText(message, "Обновление завершено успешно.");
            ClickByName("ОК", message);
        }
Ejemplo n.º 2
0
        public void Version_update()
        {
            Uninstall();

            var currentVersion = new Version(FileVersionInfo.GetVersionInfo(setupBin).ProductVersion);
            var prev           = GetPrevVersion(currentVersion);
            var prevVersion    = new Version(FileVersionInfo.GetVersionInfo(prev).ProductVersion);

            Install(prev);

            Activate();
            WaitMessage("Для начала работы с программой необходимо заполнить учетные данные", "ОК");
            Assert.That(AutomationHelper.ToText(MainWindow), Does.Contain(prevVersion.ToString()));

            Type("Settings_UserName", testUserName);
            Type("Password", testPassword);

            var dialog = WaitDialog("Настройка");

            Click("Save", dialog);
            WaitMessage("База данных программы не заполнена. Выполнить обновление?", "НЕТ");

            WaitIdle();
            Click("Update", MainWindow);
            AssertUpdate("Получена новая версия программы. Сейчас будет выполнено обновление.");

            FilterByProcess = false;
            var update = Opened.Timeout(Timeout).First();

            try {
                AssertText(update, "Внимание! Происходит обновление программы.");
            } catch (ElementNotAvailableException) {
                //предполагаем что окно закрылось быстрее чем смог считаться данные и обновление прошло успешно
            }

            update = Opened.Where(e => e.Current.Name == "Обмен данными").Timeout(30.Second()).First();
            AssertText(update, "Производится обмен данными");
            Process         = Process.GetProcessById(update.Current.ProcessId);
            FilterByProcess = true;
            MainWindow      = AutomationElement.RootElement.FindFirst(TreeScope.Children, new AndCondition(
                                                                          new PropertyCondition(AutomationElement.ProcessIdProperty, Process.Id),
                                                                          new PropertyCondition(AutomationElement.NameProperty, "АналитФАРМАЦИЯ - Новости")));
            if (MainWindow == null)
            {
                var windows = AutomationElement.RootElement.FindAll(TreeScope.Children, new AndCondition(
                                                                        new PropertyCondition(AutomationElement.ProcessIdProperty, Process.Id),
                                                                        new PropertyCondition(AutomationElement.IsWindowPatternAvailableProperty, true)))
                              .OfType <AutomationElement>()
                              .Implode(x => x.Current.Name);
                Assert.Fail($"Не удалось найти главное окно с заголовком 'АналитФАРМАЦИЯ' у процесса {Process.Id} есть следующие окна {windows}");
            }

            var message = Opened.Timeout(UpdateTimeout).First();

            AssertText(message, "Обновление завершено успешно.");
            Assert.That(AutomationHelper.ToText(MainWindow), Does.Contain(currentVersion.ToString()));
            ClickByName("ОК", message);
        }