Example #1
0
 /// <summary>
 /// Adds the missing steps to a file already existing through use of the skeletonProvider.
 /// Shows a message if succesful.
 /// </summary>
 private void AddStepsToFile(IStepDefinitionSkeletonProvider skeletonProvider,
     List<StepInstance> missingSteps, string classExtension)
 {
     string dir = Path.GetDirectoryName(_featurePath);
     OpenFileDialog ofd = new OpenFileDialog
     {
         DefaultExt = ".cs",
         Title = "Choose the file your step definitions should be added to.",
         InitialDirectory = dir,
         FileName = _suggestedStepDefName
     };
     DialogResult dialogResult = ofd.ShowDialog();
     if (dialogResult == DialogResult.OK)
     {
         try
         {
             string contents = _handler.GetFileText(ofd.FileName, classExtension);
             string newText = skeletonProvider.AddStepsToExistingFile(contents, missingSteps);
             if (!String.IsNullOrEmpty(newText))
             {
                 _handler.WriteToFile(newText, true, ofd.FileName);
                 MessageBox.Show("Success! Your steps have been added successfully",
                                 MessageBoxHeader);
             }
             else
             {
                 MessageBox.Show("The file you selected does not contain a binding class",
                                 MessageBoxHeader, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (FileHandlerException fileHandlerException)
         {
             MessageBox.Show(fileHandlerException.Message, MessageBoxHeader,
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }