public void ToDialog()
        {
            // Arrange
            settings.AddExtension     = false;
            settings.CheckFileExists  = false;
            settings.CheckPathExists  = false;
            settings.CreatePrompt     = true;
            settings.DefaultExt       = "txt";
            settings.FileName         = "SomeFile.txt";
            settings.FileNames        = new[] { "SomeFile.txt" };
            settings.Filter           = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
            settings.FilterIndex      = 2;
            settings.InitialDirectory = @"C:\temp";
            settings.OverwritePrompt  = true;
            settings.Title            = "Some Title";

            // Act
            sync.ToDialog();

            // Assert
            Assert.That(dialog.AddExtension, Is.EqualTo(settings.AddExtension));
            Assert.That(dialog.CheckFileExists, Is.EqualTo(settings.CheckFileExists));
            Assert.That(dialog.CheckPathExists, Is.EqualTo(settings.CheckPathExists));
            Assert.That(dialog.CreatePrompt, Is.EqualTo(settings.CreatePrompt));
            Assert.That(dialog.DefaultExt, Is.EqualTo(settings.DefaultExt));
            Assert.That(dialog.FileName, Is.EqualTo(settings.FileName));
            Assert.That(dialog.FileNames, Is.EqualTo(settings.FileNames));
            Assert.That(dialog.Filter, Is.EqualTo(settings.Filter));
            Assert.That(dialog.FilterIndex, Is.EqualTo(settings.FilterIndex));
            Assert.That(dialog.InitialDirectory, Is.EqualTo(settings.InitialDirectory));
            Assert.That(dialog.OverwritePrompt, Is.EqualTo(settings.OverwritePrompt));
            Assert.That(dialog.Title, Is.EqualTo(settings.Title));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SaveFileDialogWrapper"/> class.
        /// </summary>
        /// <param name="settings">The settings for the save file dialog.</param>
        public SaveFileDialogWrapper(SaveFileDialogSettings settings)
        {
            dialog = new SaveFileDialog();
            sync   = new SaveFileDialogSettingsSync(dialog, settings);

            // Update dialog
            sync.ToDialog();
        }
Example #3
0
        public void ToDialog()
        {
            // Arrange
            var dialog   = new SaveFileDialog();
            var settings = new SaveFileDialogSettings();
            var sync     = new SaveFileDialogSettingsSync(dialog, settings);

            settings.AddExtension     = !settings.AddExtension;
            settings.CheckFileExists  = !settings.CheckFileExists;
            settings.CheckPathExists  = !settings.CheckPathExists;
            settings.CreatePrompt     = !settings.CreatePrompt;
            settings.CustomPlaces     = new List <FileDialogCustomPlace>(new[] { new FileDialogCustomPlace(Guid.NewGuid()) });
            settings.DefaultExt       = "txt";
            settings.DereferenceLinks = !settings.DereferenceLinks;
            settings.FileName         = "SomeFile.txt";
            settings.FileNames        = new[] { "SomeFile.txt" };
            settings.Filter           = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
            settings.FilterIndex      = 2;
            settings.InitialDirectory = @"C:\temp";
            settings.OverwritePrompt  = !settings.OverwritePrompt;
            settings.SafeFileName     = "SomeFile.txt";
            settings.SafeFileNames    = new[] { "SomeFile.txt" };
            settings.Title            = "Some Title";
            settings.ValidateNames    = !settings.ValidateNames;

            // Act
            sync.ToDialog();

            // Assert
            Assert.That(dialog.AddExtension, Is.EqualTo(settings.AddExtension));
            Assert.That(dialog.CheckFileExists, Is.EqualTo(settings.CheckFileExists));
            Assert.That(dialog.CheckPathExists, Is.EqualTo(settings.CheckPathExists));
            Assert.That(dialog.CreatePrompt, Is.EqualTo(settings.CreatePrompt));
            Assert.That(dialog.CustomPlaces, Is.EqualTo(settings.CustomPlaces));
            Assert.That(dialog.DefaultExt, Is.EqualTo(settings.DefaultExt));
            Assert.That(dialog.DereferenceLinks, Is.EqualTo(settings.DereferenceLinks));
            Assert.That(dialog.FileName, Is.EqualTo(settings.FileName));
            Assert.That(dialog.FileNames, Is.EqualTo(settings.FileNames));
            Assert.That(dialog.Filter, Is.EqualTo(settings.Filter));
            Assert.That(dialog.FilterIndex, Is.EqualTo(settings.FilterIndex));
            Assert.That(dialog.InitialDirectory, Is.EqualTo(settings.InitialDirectory));
            Assert.That(dialog.OverwritePrompt, Is.EqualTo(settings.OverwritePrompt));
            Assert.That(dialog.SafeFileName, Is.EqualTo(settings.SafeFileName));
            Assert.That(dialog.SafeFileNames, Is.EqualTo(settings.SafeFileNames));
            Assert.That(dialog.Title, Is.EqualTo(settings.Title));
            Assert.That(dialog.ValidateNames, Is.EqualTo(settings.ValidateNames));
        }