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 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 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;
            }
        }