Esempio n. 1
0
        public void GetVersionClientUrlHostNotFound()
        {
            var mockCxSettings = new Mock <ISitecoreConnectionSettings>();

            mockCxSettings.SetupGet(cxSettings => cxSettings.ClientUrl).Returns("http://localhost/sitecore");
            var manager  = new SitecoreConnectionManager(mockCxSettings.Object);
            var response = manager.GetSitecoreVersion();

            Assert.IsNotNull(response);
            Assert.IsNull(response.Data);
            Assert.IsNotNull(response.GetExceptions());
            Assert.IsTrue(response.GetExceptions().Any());
        }
Esempio n. 2
0
        public void GetVersionSitecore80()
        {
            var mockCxSettings = new Mock <ISitecoreConnectionSettings>();

            mockCxSettings.SetupGet(cxSettings => cxSettings.ClientUrl).Returns("http://sc80/sitecore");
            var manager  = new SitecoreConnectionManager(mockCxSettings.Object);
            var response = manager.GetSitecoreVersion();

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Data);
            Assert.AreEqual(8, response.Data.Major);
            Assert.AreEqual(0, response.Data.Minor);
            Assert.IsNotNull(response.GetExceptions());
            Assert.IsFalse(response.GetExceptions().Any());
        }
        protected virtual Version GetSitecoreVersion(SitecoreConnectionManager manager)
        {
            var response = manager.GetSitecoreVersion();

            if (response == null)
            {
                MessageBox.Show("GetSitecoreVersion() returned a null response.", TEST_CONNECTION_CAPTION, MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
            if (response.Data == null)
            {
                var b1 = new StringBuilder();
                b1.AppendLine("The Sitecore server version could not be determined.\n\nThe following messages were returned:\n");
                b1.AppendLine(string.Join("\n", response.GetExceptions().Select(ex => string.Format("* {0}", ex.Message))));
                MessageBox.Show(b1.ToString(), TEST_CONNECTION_CAPTION, MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
            return(response.Data);
        }