Esempio n. 1
0
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <FileDialog>()))
            .Returns(new FileDialogResult {
                DialogResult = true, FileName = "unused.config"
            });

            UIServiceMock.Setup(x => x.ShowError(It.IsAny <string>())).Verifiable();

            appModel = Container.Resolve <ApplicationViewModel>();
            appModel.NewEnvironment();
            var validEnvironment = appModel.Environments.ElementAt(0);

            validEnvironment.EnvironmentDeltaFile = "mydeltafile.dconfig";
            Assert.IsFalse(validEnvironment.Properties
                           .SelectMany(p => p.ValidationResults)
                           .Where(e => e.IsError).Any());

            appModel.NewEnvironment();
            var invalidEnvironment = appModel.Environments.ElementAt(0);

            invalidEnvironment.EnvironmentDeltaFile = string.Empty;

            Assert.IsTrue(invalidEnvironment.Properties
                          .SelectMany(p => p.ValidationResults)
                          .Where(e => e.IsError).Any());
        }
        public void then_saving_again_doesnt_prompt_to_overwrite_file()
        {
            UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsRegex("overwrite", RegexOptions.None), It.IsAny <string>(), System.Windows.MessageBoxButton.OKCancel))
            .Callback(() => Assert.Fail());

            applicationModel.Save();
        }
        protected override void Arrange()
        {
            targetFile            = "empty.dconfig";
            environmentConfigFile = "empty.config";

            ResourceHelper <ConfigFileLocator> helper = new ResourceHelper <ConfigFileLocator>();

            helper.DumpResourceFileToDisk(targetFile);
            helper.DumpResourceFileToDisk(environmentConfigFile);

            mainFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "any.config");
            base.Arrange();

            applicationModel = (ApplicationViewModel)Container.Resolve <IApplicationModel>();
            applicationModel.ConfigurationFilePath = mainFile;

            ConfigurationSourceModel sourceModel = Container.Resolve <ConfigurationSourceModel>();

            applicationModel.NewEnvironment();

            applicationModel.Environments.First().EnvironmentDeltaFile         = targetFile;
            applicationModel.Environments.First().EnvironmentConfigurationFile = environmentConfigFile;

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <SaveFileDialog>()))
            .Callback(() => Assert.Fail());

            UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsRegex("overwrite", RegexOptions.None), It.IsAny <string>(), System.Windows.MessageBoxButton.OKCancel))
            .Returns(MessageBoxResult.Yes)
            .Verifiable();
        }
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.YesNoCancel))
            .Returns(MessageBoxResult.Yes)
            .Verifiable();
        }
 protected override void Act()
 {
     UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <FileDialog>())).Returns(new FileDialogResult {
         DialogResult = false
     });
     UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
     ApplicationModel.OpenConfigurationSource();
 }
Esempio n. 6
0
 protected override void Arrange()
 {
     base.Arrange();
     base.UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <SaveFileDialog>())).Returns(new FileDialogResult {
         DialogResult = true, FileName = SaveAsTargetFile
     });
     UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
 }
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <SaveFileDialog>()))
            .Returns(new FileDialogResult {
                DialogResult = false
            })
            .Verifiable();
        }
Esempio n. 8
0
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), It.Is <MessageBoxButton>(b => b == MessageBoxButton.YesNo)))
            .Returns(MessageBoxResult.No).Verifiable();

            configurationSourceModel = Container.Resolve <ConfigurationSourceModel>();
            configurationSourceModel.AddSection(LoggingSettings.SectionName, new LoggingSettings());
        }
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.YesNoCancel))
            .Returns(MessageBoxResult.Cancel)
            .Verifiable();

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <OpenFileDialog>())).Callback(() => Assert.Fail());
        }
        protected override void Arrange()
        {
            base.Arrange();
            string hierarchicalConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "hierarchical_config.config");

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <FileDialog>())).Returns(new FileDialogResult {
                DialogResult = true, FileName = hierarchicalConfigurationPath
            });
            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
        }
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <FileDialog>())).Returns(new FileDialogResult {
                DialogResult = true, FileName = TestConfigurationFilePath
            });
            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <WaitDialog>())).Verifiable("Wait dialog not displayed");
            shellServiceChangedListener = new PropertyChangedListener(ApplicationModel);
        }
Esempio n. 12
0
        protected override void Arrange()
        {
            base.Arrange();

            File.WriteAllText(SaveAsTargetFile, "this is a text file now");
            lastWriteTimeSaveAsTarget = File.GetLastWriteTime(SaveAsTargetFile);

            UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.OKCancel))
            .Returns(MessageBoxResult.OK)
            .Verifiable();
        }
        protected override void Arrange()
        {
            base.Arrange();

            ApplicationModel.NewEnvironment();
            ApplicationModel.Environments.ElementAt(0).EnvironmentDeltaFile = string.Format("unused{0}.dconfig", Guid.NewGuid().ToString("D"));

            UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.YesNoCancel))
            .Returns(MessageBoxResult.Yes)
            .Verifiable();
        }
Esempio n. 14
0
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <FileDialog>()))
            .Returns(new FileDialogResult {
                DialogResult = true, FileName = "unused.config"
            });

            UIServiceMock.Setup(x => x.ShowError(It.IsAny <string>())).AtMost(0);
        }
        protected override void Act()
        {
            environmentDeltaFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "environment.dconfig");

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <OpenFileDialog>()))
            .Returns(new FileDialogResult
            {
                DialogResult = true,
                FileName     = environmentDeltaFilePath
            });
            var openEnvironmentDelta = Container.Resolve <OpenEnvironmentConfigurationDeltaCommand>();

            openEnvironmentDelta.Execute(null);
        }
        protected override void Arrange()
        {
            base.Arrange();

            lastWriteTimeInArrange = File.GetLastWriteTime(TestConfigurationFilePath);
            File.SetAttributes(TestConfigurationFilePath, FileAttributes.ReadOnly);

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <SaveFileDialog>()))
            .Callback(() => Assert.Fail());

            UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.YesNoCancel))
            .Returns(MessageBoxResult.Cancel)
            .Verifiable();
        }
        protected override void Arrange()
        {
            base.Arrange();
            string errorSectionConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "configuration_error.config");

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <OpenFileDialog>()))
            .Returns(new FileDialogResult {
                DialogResult = true, FileName = errorSectionConfigurationPath
            });
            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>())).Callback <Window>((w) => w.Closed += (o, e) => waitClosed = true);

            UIServiceMock.Setup(x => x.ShowError(It.IsAny <ConfigurationErrorsException>(), It.IsAny <string>()))
            .Verifiable();
        }
        protected override void Act()
        {
            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <FileDialog>())).Returns(new FileDialogResult {
                DialogResult = true, FileName = TestConfigurationFilePath
            });
            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
            ApplicationModel.OpenConfigurationSource();

            Assert.IsFalse(ApplicationModel.IsDirty);
            ApplicationModelChangedListener.ChangedProperties.Clear();

            ConfigurationSourceModel sourceModel = Container.Resolve <ConfigurationSourceModel>();

            sourceModel.AddSection("my section", new ConnectionStringsSection());
        }
        protected override void Arrange()
        {
            base.Arrange();
            ApplicationModel.SetDirty();

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <SaveFileDialog>()))
            .Returns(new FileDialogResult {
                DialogResult = false
            })
            .Verifiable();

            base.UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.YesNoCancel))
            .Returns(MessageBoxResult.Yes)
            .Verifiable();
        }
Esempio n. 20
0
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
            UIServiceMock.Setup(
                x => x.ShowError(It.IsAny <Exception>(), It.IsAny <string>()));

            var resources = new ResourceHelper <ConfigFileLocator>();

            resources.DumpResourceFileToDisk(sourceFileName);
            resources.DumpResourceFileToDisk("configurationsource_invalid_satellite.config");

            applicationModel = Container.Resolve <IApplicationModel>();
        }
Esempio n. 21
0
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
            UIServiceMock.Setup(
                x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>())).Returns(
                MessageBoxResult.OK);

            var resources = new ResourceHelper <ConfigFileLocator>();

            resources.DumpResourceFileToDisk(sourceFileName);

            applicationModel = Container.Resolve <IApplicationModel>();
        }
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(
                x =>
                x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <System.Windows.MessageBoxButton>()))
            .Returns(MessageBoxResult.No);

            var sectionViewModel = SourceModel.Sections.First();

            elementWeakReferences         = sectionViewModel.DescendentElements().Union(new[] { sectionViewModel }).Select(e => new WeakReference(e)).ToArray();
            elementPropertyWeakReferences =
                sectionViewModel.DescendentElements().Union(new[] { sectionViewModel }).SelectMany(e => e.Properties).Select(
                    p => new WeakReference(p)).ToArray();
        }
Esempio n. 23
0
        protected override void Arrange()
        {
            base.Arrange();

            var resources = new ResourceHelper <ConfigFileLocator>();

            resources.DumpResourceFileToDisk("configurationsource_main_with_missing.config");

            designSource             = new DesignConfigurationSource("configurationsource_main_with_missing.config");
            configurationSourceModel = Container.Resolve <ConfigurationSourceModel>();

            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
            UIServiceMock.Setup(
                x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>()))
            .Returns(MessageBoxResult.OK).Verifiable("Message not invoked");
        }
Esempio n. 24
0
        protected override void Arrange()
        {
            base.Arrange();

            var resources = new ResourceHelper <ConfigFileLocator>();

            resources.DumpResourceFileToDisk("configurationsource_with_invalid_satellite.config");
            resources.DumpResourceFileToDisk("configurationsource_invalid_satellite.config");

            designSource             = new DesignConfigurationSource("configurationsource_with_invalid_satellite.config");
            configurationSourceModel = Container.Resolve <ConfigurationSourceModel>();

            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
            UIServiceMock.Setup(
                x => x.ShowError(It.IsAny <Exception>(), It.IsAny <string>())).Verifiable();
        }
Esempio n. 25
0
        protected override void Arrange()
        {
            originalFileContents = File.ReadAllText(TestConfigurationFilePath);
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <FileDialog>())).Returns(new FileDialogResult {
                DialogResult = true, FileName = TestConfigurationFilePath
            });
            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));

            ApplicationModel.OpenConfigurationSource();

            SaveOperation saveOperation = Container.Resolve <SaveOperation>();

            saveOperationBeginFired           = false;
            saveOperationEndFired             = false;
            saveOperation.BeginSaveOperation += (sender, args) => saveOperationBeginFired = true;
            saveOperation.EndSaveOperation   += (sender, args) => saveOperationEndFired = true;
        }
        protected override void Arrange()
        {
            base.Arrange();

            ((EnvironmentSourceViewModel)EnvironmentViewModel).EnvironmentDeltaFile         = string.Empty;
            ((EnvironmentSourceViewModel)EnvironmentViewModel).EnvironmentConfigurationFile = string.Empty;

            ApplicationViewModel appModel = (ApplicationViewModel)Container.Resolve <IApplicationModel>();

            appModel.ConfigurationFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "empty.config");
            appModel.IsDirty = false;

            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <SaveFileDialog>()))
            .Returns(new FileDialogResult {
                DialogResult = true, FileName = "mergedconfig.config"
            })
            .Verifiable();
        }
        protected override void Arrange()
        {
            base.Arrange();

            IApplicationModel applicationModel = Container.Resolve <IApplicationModel>();

            applicationModel.SetDirty();

            UIServiceMock.Setup(x => x.ShowWindow(It.IsAny <Window>()));
            UIServiceMock
            .Setup(x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), System.Windows.MessageBoxButton.OKCancel))
            .Returns(MessageBoxResult.OK)
            .Verifiable();
            UIServiceMock
            .Setup(x => x.ShowFileDialog(It.IsAny <SaveFileDialog>()))
            .Returns(new FileDialogResult {
                FileName = "save_as.config", DialogResult = false
            })
            .Verifiable();
        }
        protected override void Arrange()
        {
            base.Arrange();

            ApplicationModel.NewEnvironment();

            var environment = ApplicationModel.Environments.ElementAt(0);

            environment.EnvironmentDeltaFile = "myenvironment.dconfig";

            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <SaveFileDialog>()))
            .Returns(new FileDialogResult {
                DialogResult = false
            })
            .Verifiable();

            base.UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.YesNoCancel))
            .Returns(MessageBoxResult.No)
            .Verifiable();
        }
        protected override void Arrange()
        {
            base.Arrange();

            UIServiceMock.Setup(x => x.ShowDialog(It.IsAny <WizardView>()))
            .Callback((Window w) => { viewCreated = w; })
            .Returns(true).Verifiable("ShowDialog not invoked.");

            resolver = new Mock <IResolver <WizardModel> >();
            resolver.Setup(x => x.Resolve(It.Is <Type>(t => t == typeof(MockWizard))))
            .Returns(new MockWizard(UIServiceMock.Object))
            .Verifiable("IResolver not invoked");

            command = new WizardCommand(
                new WizardCommandAttribute(typeof(WizardCommand))
            {
                WizardType = typeof(MockWizard)
            },
                UIServiceMock.Object,
                resolver.Object
                );
        }
        protected override void Arrange()
        {
            targetFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format("{0}.dconfig", Guid.NewGuid()));

            base.Arrange();

            overridesModel = (EnvironmentSourceViewModel)SectionViewModel.CreateSection(Container, EnvironmentalOverridesSection.EnvironmentallyOverriddenProperties, new EnvironmentalOverridesSection
            {
                EnvironmentName = "environment"
            });

            ApplicationViewModel applicationModel = Container.Resolve <ApplicationViewModel>();

            applicationModel.ConfigurationFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "main.config");


            UIServiceMock.Setup(x => x.ShowFileDialog(It.IsAny <SaveFileDialog>()))
            .Returns(new FileDialogResult {
                FileName = targetFile, DialogResult = true
            })
            .Verifiable();
        }