public void SetCxSettingsNull() { var mockCxInfo = new Mock<IConnectionInfo>(); var element = XElement.Parse((string)this.TestContext.DataRow["driverData"]); mockCxInfo.SetupGet(cxInfo => cxInfo.DriverData).Returns(element); var cxSettings = new SitecoreConnectionSettings(); var mapper = new DriverDataCxSettingsMapper(); mapper.Read(mockCxInfo.Object, cxSettings); var view = new ConnectionDialog(); view.InitializeComponent(); var driverSettings = new SitecoreDriverSettings() { CxInfo = mockCxInfo.Object, CxSettings = cxSettings, SettingsMapper = new DriverDataCxSettingsMapper() }; view.Model = driverSettings; var controller = new DriverSettingsController(view); controller.LoadView(driverSettings); view.SaveViewToModelCallback = controller.SaveView; // //basic settings view.ClientUrl = null; view.Username = null; view.Password = null; view.WebRootPath = null; view.ContextDatabaseName = null; // //advanced settings view.NamespacesToAdd = null; view.SearchResultType = null; view.AppConfigReaderType = null; view.SchemaBuilderType = null; view.DriverInitializerType = null; }
public void SetCxSettingsWithEmptyObjectsForAdvancedSettings() { var mockCxInfo = new Mock<IConnectionInfo>(); var element = XElement.Parse((string)this.TestContext.DataRow["driverData"]); mockCxInfo.SetupGet(cxInfo => cxInfo.DriverData).Returns(element); var cxSettings = new SitecoreConnectionSettings(); var mapper = new DriverDataCxSettingsMapper(); mapper.Read(mockCxInfo.Object, cxSettings); var view = new ConnectionDialog(); view.InitializeComponent(); var driverSettings = new SitecoreDriverSettings() { CxInfo = mockCxInfo.Object, CxSettings = cxSettings, SettingsMapper = new DriverDataCxSettingsMapper() }; view.Model = driverSettings; var controller = new DriverSettingsController(view); controller.LoadView(driverSettings); view.SaveViewToModelCallback = controller.SaveView; // //basic settings view.ClientUrl = "http://localhost"; view.Username = "******"; view.Password = "******"; view.WebRootPath = @"C:\Windows\Temp"; view.ContextDatabaseName = "master"; // //advanced settings view.NamespacesToAdd = new HashSet<string>(); view.SearchResultType = new SelectedType(); view.AppConfigReaderType = new SelectedType(); view.SchemaBuilderType = new SelectedType(); view.DriverInitializerType = new SelectedType(); }
public void Read() { var tmpCxStringsFile = Path.GetTempFileName(); var tmpCxStringsDoc = XDocument.Parse("<aaa></aaa>"); tmpCxStringsDoc.Save(tmpCxStringsFile); var tmpWebConfigFile = Path.GetTempFileName(); var tmpWebConfigDoc = XDocument.Parse((string) this.TestContext.DataRow["fileSystem"]); var csElement = tmpWebConfigDoc.XPathSelectElement("/configuration/connectionStrings"); var attr = csElement.Attribute("configSource"); if (attr != null) { attr.Value = tmpCxStringsFile; } tmpWebConfigDoc.Save(tmpWebConfigFile); var mockCxSettings = new Mock<ISitecoreConnectionSettings>(); mockCxSettings.SetupGet(cxSettings => cxSettings.WebRootPath).Returns(Path.GetDirectoryName(tmpWebConfigFile)); var driverSettings = new SitecoreDriverSettings() {CxSettings = mockCxSettings.Object}; var mockManager = new Mock<ISitecoreConnectionManager>(); var response = new ServerResponse<XElement>(); response.Data = XElement.Parse((string)this.TestContext.DataRow["server"]); mockManager.Setup(m => m.GetSitecoreConfig()).Returns(response); var reader = new Sitecore8AppConfigReader(); var doc = reader.Read(mockManager.Object, driverSettings, tmpWebConfigFile, false); // //Test by re-running the transformers. No changes should be reported. var transformers = reader.GetTransformers(driverSettings); foreach (var transformer in transformers) { Assert.IsFalse(transformer.Transform(doc)); } }
public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection) { var view = new ConnectionDialog(); if (!view.IsInitialized) { view.InitializeComponent(); } try { var settings = GetCxSettings(cxInfo); var driverSettings = new SitecoreDriverSettings() { CxInfo = cxInfo, CxSettings = settings, SettingsMapper = new DriverDataCxSettingsMapper() }; view.Model = driverSettings; var controller = new DriverSettingsController(view); controller.LoadView(driverSettings); view.SaveViewToModelCallback = controller.SaveView; var result = view.ShowDialog(); return (result == true); } catch (Exception ex) { var message = string.Format("An exception was thrown when trying to load the dialog.\n\n" + "You might need to manually edit the connections file located in {0}.\n\n" + "=====================================\n" + "{1}\n{2}", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "LINQPad"), ex.Message, ex.StackTrace); MessageBox.Show(view, message, "Connection Dialog", MessageBoxButton.OK, MessageBoxImage.Error); return false; } }