コード例 #1
0
ファイル: LogFacts.cs プロジェクト: pars87/Catel
            public void WriteMessagesWithUnIndent()
            {
                LogManager.RegisterDebugListener();
                var log = new Log(typeof(int));

                LogMessageEventArgs eventArgs = null;
                log.LogMessage += (sender, e) => eventArgs = e;

                log.Indent();
                log.Info("Indented message");
                log.Unindent();
                log.Info("Unindented message");

                Assert.IsNotNull(eventArgs);
                Assert.AreEqual(log, eventArgs.Log);
                Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent);
                Assert.AreEqual("[System.Int32] Unindented message", eventArgs.Message);
            }
コード例 #2
0
        /// <summary>
        /// Activates the dataset with the given ID.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="log">The log object.</param>
        /// <param name="id">The ID of the dataset that should be activated.</param>
        public static void ActivateDataset(Application application, Log log, int id)
        {
            const string prefix = "Project page - Activate dataset";
            if (IsDatasetActivated(application, log, id))
            {
                log.Info(
                    prefix,
                    "Dataset is already activated.");
                return;
            }

            var tab = TabProxies.GetProjectPageTabItem(application, log);
            if (tab == null)
            {
                throw new RegressionTestFailedException(prefix + " - Failed to get project tab.");
            }

            var datasets = GetDatasetControls(application, log);
            if (datasets.Count == 0)
            {
                throw new RegressionTestFailedException(prefix + " - Failed to get dataset controls.");
            }

            if (!datasets.ContainsKey(id))
            {
                throw new RegressionTestFailedException(prefix + " - Failed to find dataset with id: " + id.ToString(CultureInfo.InvariantCulture));
            }

            var buttonId = string.Format(
                CultureInfo.InvariantCulture,
                "Button_[{0}_[DatasetId: [{1}]]]",
                DatasetViewAutomationIds.DatasetActivateDeactivate,
                id);
            var buttonSearchCriteria = SearchCriteria
                .ByAutomationId(buttonId);
            var button = tab.Get<Button>(buttonSearchCriteria);
            if (button == null)
            {
                throw new RegressionTestFailedException(prefix + " - Failed to get activate dataset button.");
            }

            try
            {
                button.Click();
            }
            catch (Exception e)
            {
                throw new RegressionTestFailedException(prefix + " - Failed to activate the dataset.", e);
            }

            // handle dialog
            SelectMachineForDatasetActivation(application, log);

            // Wait for the dataset to be activated
            WaitForDatasetActivation(application, log, id);
        }
コード例 #3
0
ファイル: ControlProxies.cs プロジェクト: pvandervelde/Apollo
        /// <summary>
        /// Manually searches for a <see cref="UIItem"/> in a container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="automationId">The automation ID for the control.</param>
        /// <param name="log">The log object.</param>
        /// <returns>The control if it can be found; otherwise, <see langword="null" />.</returns>
        public static IUIItem FindItemManuallyInUIContainer(UIItemContainer container, string automationId, Log log)
        {
            const string logPrefix = "Controls - Find element manually";
            log.Debug(
                logPrefix,
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Searching for UI element with ID: [{0}].",
                    automationId));

            if ((container == null) || string.IsNullOrEmpty(automationId))
            {
                return null;
            }

            var stack = new Stack<UIItemContainer>();
            stack.Push(container);
            while (stack.Count > 0)
            {
                var localContainer = stack.Pop();
                foreach (var element in localContainer.Items)
                {
                    log.Debug(
                        logPrefix,
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "Found UI item of type [{0}] with ID: [{1}]. Name: [{2}]",
                            element.GetType().Name,
                            element.Id,
                            element.Name));
                    if (string.Equals(element.Id, automationId, StringComparison.Ordinal))
                    {
                        log.Info(
                            logPrefix,
                            string.Format(
                                CultureInfo.InvariantCulture,
                                "Found desired element of type [{0}] with ID: [{1}]",
                                element.GetType().Name,
                                element.Id));
                        return element;
                    }

                    var subContainer = element as UIItemContainer;
                    if (subContainer != null)
                    {
                        stack.Push(subContainer);
                    }
                }
            }

            return null;
        }
コード例 #4
0
        public static void ExitApplication(Application application, Log log)
        {
            const string prefix = "Application - Exit";
            if (application != null)
            {
                log.Info(prefix, "Closing application.");
                try
                {
                    application.Close();
                    if (application.Process.HasExited)
                    {
                        return;
                    }

                    application.Process.WaitForExit(Constants.ShutdownWaitTimeInMilliSeconds());
                    if (!application.Process.HasExited)
                    {
                        application.Kill();
                    }
                }
                catch (InvalidOperationException)
                {
                    // Do nothing because the cause for this exception is when there is no process
                    // associated with the application.Process object.
                }
                catch (Exception e)
                {
                    log.Error(
                        prefix,
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "Error trying to terminate application. Error was: {0}",
                            e));
                }
            }
        }
コード例 #5
0
        private static string FindApolloInstallDirectoryInDevelopmentLocation(Log log)
        {
            var buildDirectory = Constants.GetPathOfExecutingScript();
            if (!string.IsNullOrEmpty(buildDirectory))
            {
                // Move down the directory structure to find the final file
                var explorerFiles = Directory.GetFiles(buildDirectory, Constants.GetApolloExplorerFileName(), SearchOption.AllDirectories);
                if (explorerFiles.Length == 1)
                {
                    log.Info(
                        "Application - Search development directory",
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "Found apollo explorer at [{0}].",
                            buildDirectory));

                    return Path.GetDirectoryName(explorerFiles[0]);
                }
            }

            return null;
        }
コード例 #6
0
ファイル: VerifyViews.cs プロジェクト: pvandervelde/Apollo
        /// <summary>
        /// Verifies that the 'View' menu works as expected.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="log">The log object.</param>
        /// <returns>The test result for the current test case.</returns>
        public TestResult VerifyViewMenu(Application application, Log log)
        {
            const string prefix = "View menu";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                var startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage != null)
                {
                    log.Info(prefix, "Closing start page.");
                    TabProxies.CloseStartPageTab(application, log);
                }

                // Make sure we don't close the welcome tab upon opening the project page
                WelcomePageControlProxies.UncheckCloseWelcomePageOnProjectOpen(application, log);

                var projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage != null)
                {
                    log.Info(prefix, "Closing project page.");
                    TabProxies.CloseProjectPageTab(application, log);
                }

                // Open start page via view menu
                MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log);

                startPage = TabProxies.GetStartPageTabItem(application, log);
                assert.IsNotNull(startPage, prefix + " - Check start page exists after clicking start page menu item");
                assert.IsTrue(startPage.IsSelected, prefix + " - Check start page is focussed after clicking start page menu item");
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
コード例 #7
0
 public void TestConcurrency()
 {
     // start up the next log instance
      var queue = new Loggers.Queue();
      var props = new List<String>()
      {
     "Http.Uri",
     "Http.Path",
     "Http.Method",
     "Http.StatusCode",
     "Http.Status",
     "Http.Timestamp",
     "Http.User",
     "Http.SessionID",
     "Http.IPAddress",
     "Http.Request.TestHeader",
     "Http.Session.TestVariable"
      };
      using (
     Log.RegisterInstance(
        new Instance()
        {
           Logger = queue,
           Synchronous = false,
           Buffer = 0,
           Properties = props
        }
     )
      )
      {
     Log log = new Log(GetType());
     Parallel.For(0, TestParallelIterations,
        i =>
        {
           HttpContext.Current = MockHttp.CreateHttpContext();
           log.Info("test");
        }
     );
     Log.Flush();
     // verify event properties
     for (Int32 i = 0; i < TestParallelIterations; i++)
     {
        var evt = queue.Dequeue().First();
        Assert.AreEqual(evt["Http.Uri"], "http://www.tempuri.org/?Test=Value");
        Assert.AreEqual(evt["Http.Path"], "/?Test=Value");
        Assert.AreEqual(evt["Http.Method"], "HEAD");
        Assert.AreEqual(evt["Http.StatusCode"], 200);
        Assert.AreEqual(evt["Http.Status"], "200 OK");
        Assert.IsTrue((DateTime)evt["Http.Timestamp"] <= DateTime.Now);
        Assert.AreEqual(evt["Http.User"], "testuser");
        Assert.IsNotNull(evt["Http.SessionID"]);
        Assert.AreEqual(evt["Http.IPAddress"], Dns.GetHostAddresses("localhost")[0].ToString());
        Assert.AreEqual(evt["Http.Request.TestHeader"], "TestHeaderValue");
        Assert.AreEqual(evt["Http.Session.TestVariable"], "TestVariableValue");
     }
     Assert.IsFalse(queue.Dequeue().Any());
      }
 }
コード例 #8
0
        /// <summary>
        /// Starts the application.
        /// </summary>
        /// <param name="applicationPath">The full path to the application executable.</param>
        /// <param name="log">The log object.</param>
        /// <returns>The application.</returns>
        public static Application StartApplication(string applicationPath, Log log)
        {
            const string prefix = "Application - Start";
            if (string.IsNullOrEmpty(applicationPath))
            {
                return null;
            }

            if (!File.Exists(applicationPath))
            {
                return null;
            }

            var processInfo = new ProcessStartInfo
            {
                FileName = applicationPath,
                UseShellExecute = true,
                WindowStyle = ProcessWindowStyle.Maximized,
            };

            log.Info(
                prefix,
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Loading application from: {0}",
                    applicationPath));

            var application = Application.Launch(processInfo);

            log.Info(prefix, "Launched application, waiting for idle ...");
            application.WaitWhileBusy();

            log.Info(prefix, "Application launched and idle");
            return application;
        }
コード例 #9
0
ファイル: LogFacts.cs プロジェクト: paytonli2013/Catel
            public void Info_Message_Null()
            {
                LogManager.RegisterDebugListener();
                var log = new Log(typeof (int));

                log.Info((string) null);
            }
コード例 #10
0
ファイル: VerifyViews.cs プロジェクト: pvandervelde/Apollo
        public TestResult VerifyCloseOnProjectOpenCheckbox(Application application, Log log)
        {
            const string prefix = "Close welcome tab on project open";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                var startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    log.Info(prefix, "Opening start page.");
                    MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log);
                }

                startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    var message = "Failed to get the start page.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                try
                {
                    if (!startPage.IsSelected)
                    {
                        log.Info(prefix, "Setting focus to start page.");
                        startPage.Select();
                    }
                }
                catch (Exception e)
                {
                    var message = string.Format(
                        CultureInfo.InvariantCulture,
                        "Failed to select the start page tab. Error was: {0}",
                        e);
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);

                    return result;
                }

                // Check 'keep open' flag
                WelcomePageControlProxies.UncheckCloseWelcomePageOnProjectOpen(application, log);

                // New button
                var newProjectSearchCriteria = SearchCriteria
                    .ByAutomationId(WelcomeViewAutomationIds.NewProject);
                var newProjectButton = (Button)startPage.Get(newProjectSearchCriteria);
                if (newProjectButton == null)
                {
                    var message = "Failed to get the 'New Project' button.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                newProjectButton.Click();

                // Check that the start page hasn't been closed
                var currentStartPage = TabProxies.GetStartPageTabItem(application, log);
                assert.IsNotNull(currentStartPage, prefix + " - Start page does not exist after opening project");
                assert.IsFalse(currentStartPage.IsSelected, prefix + " - Start page is selected after opening project");

                var currentProjectPage = TabProxies.GetProjectPageTabItem(application, log);
                assert.IsNotNull(currentProjectPage, prefix + " - Project page does not exist after opening project");
                assert.IsTrue(currentProjectPage.IsSelected, prefix + " - Project page is not selected after opening project");

                // Check that File - close has been enabled
                var fileCloseMenu = MenuProxies.GetFileCloseMenuItem(application, log);
                assert.IsTrue(fileCloseMenu.Enabled, prefix + " - File - Close menu is not enabled");

                // HACK: It seems that the File menu stays open when we check the File - close menu item
                var fileMenu = MenuProxies.GetFileMenuItem(application, log);
                if (fileMenu == null)
                {
                    var message = "Failed to get the file menu.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                if (fileMenu.IsFocussed)
                {
                    fileMenu.Click();
                }

                // Close the project via the close button on the tab page
                TabProxies.CloseProjectPageTab(application, log);

                WelcomePageControlProxies.CheckCloseWelcomePageOnProjectOpen(application, log);

                // New button
                newProjectButton.Click();

                // Check that the start page has been closed
                currentStartPage = TabProxies.GetStartPageTabItem(application, log);
                assert.IsNull(currentStartPage, prefix + " - Start page exists after opening project");

                // Close the project via the close button on the tab page
                TabProxies.CloseProjectPageTab(application, log);
                WelcomePageControlProxies.UncheckCloseWelcomePageOnProjectOpen(application, log);
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
コード例 #11
0
ファイル: LogFacts.cs プロジェクト: justdude/DbExport
            public void Info_ExceptionWithMessage_ExceptionNull()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof (int));

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Info(null, string.Empty));
            }
コード例 #12
0
ファイル: LogFacts.cs プロジェクト: justdude/DbExport
            public void Info_ExceptionWithMessageFormat_MessageFormatNull()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof (int));

                var exception = new ArgumentNullException("log test");

                log.Info(exception, null, 1);
            }
コード例 #13
0
ファイル: LogFacts.cs プロジェクト: justdude/DbExport
            public void CorrectlyLogsMessageWithBraces()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof(int));

                log.Info("This is a string with { and sometimes and ending }");
            }
コード例 #14
0
ファイル: LogFacts.cs プロジェクト: justdude/DbExport
            public void Info_MessageFormat()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof (int));

                LogMessageEventArgs eventArgs = null;
                log.LogMessage += (sender, e) => eventArgs = e;

                log.Info("log message {0}", 1);

                Assert.IsNotNull(eventArgs);
                Assert.AreEqual(log, eventArgs.Log);
                Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent);
                Assert.AreEqual("log message 1", eventArgs.Message);
            }
コード例 #15
0
ファイル: LogFacts.cs プロジェクト: pars87/Catel
        public void Info_ExceptionWithMessageFormat_MessageFormatNull()
        {
            LogManager.RegisterDebugListener();
            var log = new Log(typeof(int));

            var exception = new ArgumentNullException("log test");

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Info(exception, null, 1));
        }
コード例 #16
0
ファイル: LogFacts.cs プロジェクト: pars87/Catel
        public void Info_Exception()
        {
            LogManager.RegisterDebugListener();
            var log = new Log(typeof(int));

            LogMessageEventArgs eventArgs = null;
            log.LogMessage += (sender, e) => eventArgs = e;

            var exception = new ArgumentNullException("log test");
            log.Info(exception);

            Assert.IsNotNull(eventArgs);
            Assert.AreEqual(log, eventArgs.Log);
            Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent);
            Assert.AreEqual(string.Format("[System.Int32] {0}\r\nParameter name: log test", ArgumentNullExceptionText), eventArgs.Message);
        }
コード例 #17
0
ファイル: LogFacts.cs プロジェクト: pars87/Catel
        public void Info_MessageFormat_Null()
        {
            LogManager.RegisterDebugListener();
            var log = new Log(typeof(int));

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Info((string)null, null));
        }
コード例 #18
0
ファイル: LogFacts.cs プロジェクト: pars87/Catel
        public void Info_Message()
        {
            LogManager.RegisterDebugListener();
            var log = new Log(typeof(int));

            LogMessageEventArgs eventArgs = null;
            log.LogMessage += (sender, e) => eventArgs = e;

            log.Info("log message");

            Assert.IsNotNull(eventArgs);
            Assert.AreEqual(log, eventArgs.Log);
            Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent);
            Assert.AreEqual("[System.Int32] log message", eventArgs.Message);
        }
コード例 #19
0
ファイル: ControlProxies.cs プロジェクト: pvandervelde/Apollo
        /// <summary>
        /// Manually searches for a <see cref="UIItem"/> in a container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="automationId">The partial automation ID for the control.</param>
        /// <param name="log">The log object.</param>
        /// <returns>A collection containing all the controls that have an automation ID that matches the partial ID.</returns>
        public static IEnumerable<IUIItem> FindItemsManuallyInUIContainerWithPartialId(UIItemContainer container, string automationId, Log log)
        {
            const string logPrefix = "Controls - Find element manually with partial ID";
            log.Debug(
                logPrefix,
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Searching for UI element with partial ID: [{0}].",
                    automationId));

            var result = new List<IUIItem>();
            if ((container == null) || string.IsNullOrEmpty(automationId))
            {
                return result;
            }

            var stack = new Stack<UIItemContainer>();
            stack.Push(container);
            while (stack.Count > 0)
            {
                var localContainer = stack.Pop();
                foreach (var element in localContainer.Items)
                {
                    log.Debug(
                        logPrefix,
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "Found UI item of type [{0}] with ID: [{1}]. Name: [{2}]",
                            element.GetType().Name,
                            element.Id,
                            element.Name));
                    if ((!string.IsNullOrEmpty(element.Id)) && element.Id.Contains(automationId))
                    {
                        log.Info(
                            logPrefix,
                            string.Format(
                                CultureInfo.InvariantCulture,
                                "Found matching element of type [{0}] with ID: [{1}]",
                                element.GetType().Name,
                                element.Id));
                        result.Add(element);
                    }

                    var subContainer = element as UIItemContainer;
                    if (subContainer != null)
                    {
                        stack.Push(subContainer);
                    }
                }
            }

            return result;
        }
コード例 #20
0
ファイル: LogFacts.cs プロジェクト: justdude/DbExport
            public void Info_MessageFormat_Null()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof (int));

                log.Info((string) null, null);
            }
コード例 #21
0
ファイル: VerifyViews.cs プロジェクト: pvandervelde/Apollo
        public TestResult VerifyWelcomeTab(Application application, Log log)
        {
            const string prefix = "Welcome tab";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                var startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    log.Info(prefix, "Opening start page.");
                    MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log);
                }

                startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    var message = "Failed to get the start page.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                try
                {
                    if (!startPage.IsSelected)
                    {
                        log.Info(prefix, "Setting focus to start page.");
                        startPage.Select();
                    }
                }
                catch (Exception e)
                {
                    var message = string.Format(
                        CultureInfo.InvariantCulture,
                        "Failed to select the start page tab. Error was: {0}",
                        e);
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);

                    return result;
                }

                var applicationNameSearchCiteria = SearchCriteria
                    .ByAutomationId(WelcomeViewAutomationIds.ApplicationName);
                var nameLabel = Retry.Times(
                    () =>
                    {
                        log.Debug(prefix, "Trying to get the application name label.");
                        var label = (Label)startPage.Get(applicationNameSearchCiteria);
                        if (label == null)
                        {
                            log.Error(prefix, "Failed to find the application name label.");
                        }

                        return label;
                    });
                if (nameLabel == null)
                {
                    var message = "Failed to get the application name label.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                var nameText = nameLabel.Text;
                assert.AreEqual(ProductInformation.ProductName, nameText, prefix + " - Product Name");
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
コード例 #22
0
ファイル: LogFacts.cs プロジェクト: justdude/DbExport
            public void Info_Exception_Null()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof (int));

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Info((Exception) null));
            }
コード例 #23
0
ファイル: VerifyViews.cs プロジェクト: pvandervelde/Apollo
        private static void VerifyAboutDialog(Application application, Log log, TestResult result)
        {
            const string prefix = "About dialog";
            var assert = new Assert(result, log);
            log.Info(prefix, "Verifying content ...");

            MenuProxies.OpenAboutDialogViaHelpAboutMenuItem(application, log);
            var dialog = DialogProxies.AboutWindow(application, log);
            if (dialog == null)
            {
                var message = "Failed to get dialog.";
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
                return;
            }

            // Check application name
            var applicationNameSearchCiteria = SearchCriteria
                .ByAutomationId(AboutAutomationIds.ProductName);
            var nameLabel = Retry.Times(() => (Label)dialog.Get(applicationNameSearchCiteria));
            if (nameLabel == null)
            {
                var message = "Failed to get name label.";
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
                return;
            }

            var nameText = nameLabel.Text;
            assert.AreEqual(ProductInformation.ProductName, nameText, prefix + " - Product name");

            // Check application version
            var applicationVersionSearchCriteria = SearchCriteria
                .ByAutomationId(AboutAutomationIds.ProductVersion);
            var versionLabel = Retry.Times(() => (Label)dialog.Get(applicationVersionSearchCriteria));
            if (versionLabel == null)
            {
                var message = "Failed to get version label.";
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
                return;
            }

            var versionText = versionLabel.Text;
            var versionAttribute = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
            var version = (versionAttribute[0] as AssemblyInformationalVersionAttribute).InformationalVersion;
            assert.AreEqual(version, versionText, prefix + " - Product version");

            // Check company name
            var companyNameSearchCriteria = SearchCriteria
                .ByAutomationId(AboutAutomationIds.CompanyName);
            var companyLabel = Retry.Times(() => (Label)dialog.Get(companyNameSearchCriteria));
            if (companyLabel == null)
            {
                var message = "Failed to get company label.";
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
                return;
            }

            var companyText = companyLabel.Text;
            assert.AreEqual(CompanyInformation.CompanyName, companyText, prefix + " - Company name");

            // Check copyright
            var copyrightSearchCriteria = SearchCriteria
                .ByAutomationId(AboutAutomationIds.Copyright);
            var copyrightLabel = Retry.Times(() => (Label)dialog.Get(copyrightSearchCriteria));
            if (copyrightLabel == null)
            {
                var message = "Failed to get copyright label.";
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
                return;
            }

            var copyrightText = copyrightLabel.Text;
            assert.AreEqual(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Copyright {0} 2009 - {1}",
                    CompanyInformation.CompanyName,
                    DateTimeOffset.Now.Year),
                copyrightText,
                prefix + " - Copyright");

            try
            {
                dialog.Close();
            }
            catch (Exception e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed to close the dialog. Error was: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }
        }
コード例 #24
0
ファイル: LogFacts.cs プロジェクト: justdude/DbExport
            public void Info_ExceptionWithMessageFormat_ExceptionNull()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof (int));

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => log.Info(null, "additional message", 1));
            }
コード例 #25
0
ファイル: VerifyViews.cs プロジェクト: pvandervelde/Apollo
        private TestResult VerifyTabBehaviour(Application application, Log log)
        {
            const string prefix = "Tabs";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                var startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    log.Info(prefix, "Opening start page.");
                    MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log);
                }

                // Make sure we don't close the welcome tab upon opening the project page
                WelcomePageControlProxies.UncheckCloseWelcomePageOnProjectOpen(application, log);

                var projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage == null)
                {
                    log.Info(prefix, "Opening project page.");
                    WelcomePageControlProxies.OpenProjectPageViaWelcomePageButton(application, log);
                }

                startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    var message = "Failed to open the start page.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage == null)
                {
                    var message = "Failed to open the project page.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                try
                {
                    if (!startPage.IsSelected)
                    {
                        log.Info(prefix, "Setting focus to start page.");
                        startPage.Select();
                    }
                }
                catch (Exception e)
                {
                    var message = string.Format(
                        CultureInfo.InvariantCulture,
                        "Failed to select the start page tab. Error was: {0}",
                        e);
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);

                    return result;
                }

                assert.IsTrue(startPage.IsSelected, prefix + " - Start is selected");
                assert.IsFalse(projectPage.IsSelected, prefix + " - Project is not selected");

                MenuProxies.SwitchToProjectPageViaViewStartPageMenuItem(application, log);
                assert.IsFalse(startPage.IsSelected, prefix + " - Start is not selected");
                assert.IsTrue(projectPage.IsSelected, prefix + " - Project is selected");

                MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log);
                assert.IsTrue(startPage.IsSelected, prefix + " - Start is selected");
                assert.IsFalse(projectPage.IsSelected, prefix + " - Project is not selected");

                TabProxies.CloseProjectPageTab(application, log);
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
コード例 #26
0
ファイル: LogFacts.cs プロジェクト: justdude/DbExport
            public void Info_ExceptionWithMessageFormat()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof (int));

                LogMessageEventArgs eventArgs = null;
                log.LogMessage += (sender, e) => eventArgs = e;

                var exception = new ArgumentNullException("log test");
                log.Info(exception, "additional message {0}", 1);

                Assert.IsNotNull(eventArgs);
                Assert.AreEqual(log, eventArgs.Log);
                Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent);
                Assert.AreEqual(string.Format("additional message 1 | {0}\r\nParameter name: log test", ArgumentNullExceptionText), eventArgs.Message);
            }
コード例 #27
0
ファイル: Program.cs プロジェクト: maxross/Crawler
        static void Main(string[] args)
        {

            idPortale = (byte)Convert.ToInt32(ConfigurationManager.AppSettings["idPortale"]);
            try
            {
                logger = new Log(typeof(Program), Assembly.GetExecutingAssembly().GetName().Name);
                logger.Info("Crawler: Start crawling. " + DateTime.Now.ToLongDateString());

                dbparams[] tipologie = new dbparams[8];
                for (int x = 0; x <= 7; x++)
                {
                    tipologie[x] = new dbparams();
                }
                tipologie[0].tipologia = “xxxx”;
                tipologie[0].idtipologia = 1;
                tipologie[0].idcategoria = 1;
                tipologie[1].tipologia = “xxxx”;
                tipologie[1].idtipologia = 3;
                tipologie[1].idcategoria = 1;
                tipologie[2].tipologia = “xxxx”;
                tipologie[2].idtipologia = 4;
                tipologie[2].idcategoria = 1;
                tipologie[3].tipologia = “xxxx”;
                tipologie[3].idtipologia = 14;
                tipologie[3].idcategoria = 1;
                tipologie[4].tipologia = “xxxx;
                tipologie[4].idtipologia = 11;
                tipologie[4].idcategoria = 1;
                tipologie[5].tipologia = “xxxx”;
                tipologie[5].idtipologia = 2;
                tipologie[5].idcategoria = 1;
                tipologie[6].tipologia = “xxxx”;
                tipologie[6].idtipologia = 10;
                tipologie[6].idcategoria = 1;
                tipologie[7].tipologia = “xxxx”;
                tipologie[7].idtipologia = 141;
                tipologie[7].idcategoria = 1;


                SqlConnection connImport01 = new SqlConnection(ConfigurationManager.ConnectionStrings["DBIMPORT01ConnectionString"].ConnectionString);
                connImport01.Open();

                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = “xxxx”;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection = connImport01;
                    cmd.CommandTimeout = 600;
                    cmd.Parameters.Add("@IdPortale", SqlDbType.TinyInt).Value = idPortale;
                    try
                    {
                        var adapt = new SqlDataAdapter();
                        adapt.SelectCommand = cmd;
                        DataTable dTable = new DataTable();
                        adapt.Fill(dTable);
                        foreach (DataRow dRow in dTable.Rows)
                        {
                            comuniConQuartieri.Add(((string)dRow["Comune"]).ToLower());
                        }
                    }
                    catch (SqlException ex)
                    {
                        logger.Error("Errore nella select comuni con quartieri", ex);
                    }
                }
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = “xxxx”;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection = connImport01;
                    cmd.CommandTimeout = 600;
                    try
                    {
                        var adapt = new SqlDataAdapter();
                        adapt.SelectCommand = cmd;
                        DataTable dTable = new DataTable();
                        adapt.Fill(dTable);
                        foreach (DataRow dRow in dTable.Rows)
                        {
                            province.Add((string)dRow["SiglaProvincia"]);
                        }
                    }
                    catch (SqlException ex)
                    {
                        logger.Error("Errore nella select province", ex);
                    }
                }


                foreach (dbparams t in tipologie)
                {
                    logger.Info("Crawling: " + t.tipologia + " vendita");
                    crawl(connImport01, "vendita", t);
                    logger.Info("Crawling: " + t.tipologia + " affitto");
                    crawl(connImport01, "affitto", t);
                }

                connImport01.Close();
                connImport01.Dispose();

                esitoSuccess = true;
                DateTime fineProcedura = DateTime.Now;
                TimeSpan span = fineProcedura.Subtract(inizioProcedura);
                double seconds = span.TotalSeconds;
                sendStatus(esitoSuccess, esitoAnnunciLavorati, esitoErrors, seconds, esitoErrorsNotes);

            }
            catch (Exception ex)
            {
                logger.Error("Errore", ex);
                esitoSuccess = false;
                DateTime fineProcedura = DateTime.Now;
                TimeSpan span = fineProcedura.Subtract(inizioProcedura);
                double seconds = span.TotalSeconds;
                sendStatus(esitoSuccess, esitoAnnunciLavorati, esitoErrors, seconds, esitoErrorsNotes);
            }



        }