Skip to content

Commit

Permalink
Merge pull request #298 from dirkrombauts/TestFormatsInGui
Browse files Browse the repository at this point in the history
Test formats in gui
  • Loading branch information
dirkrombauts committed Feb 25, 2016
2 parents 51e2ec5 + d64e6ec commit 38f52d7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
- The MsTest test result provider is now able to give the result of individual examples in a scenario outline ([#285](https://github.com/picklesdoc/pickles/issues/285)) (by [@dirkrombauts](https://github.com/dirkrombauts)).
- The SpecFlow+ Runner (formerly SpecRun) test result provider is now able to give the result of individual examples in a scenario outline. See the [documentation](http://docs.picklesdoc.com/en/latest/IntegratingTestResultsFromSpecRun/) for an important caveat. ([#286](https://github.com/picklesdoc/pickles/issues/286)) (by [@dirkrombauts](https://github.com/dirkrombauts)).
- The Cucumber test result provider is now able to give the result of individual examples in a scenario outline ([#287](https://github.com/picklesdoc/pickles/issues/287)) (by [@dirkrombauts](https://github.com/dirkrombauts)).
- The GUI now uses a combobox to display the choice of test result formats ([#297](https://github.com/picklesdoc/pickles/issues/297)) (by [@dirkrombauts](https://github.com/dirkrombauts)).


### Fixed
Expand Down
13 changes: 1 addition & 12 deletions src/Pickles/Pickles.UserInterface/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,7 @@
<CheckBox Template="{StaticResource ResourceKey=myCheckBox}" Grid.Column="3" Grid.Row="7" IsChecked="{Binding Path=IsTestResultsFileValid}" Visibility="{Binding Path=IncludeTests, Converter={StaticResource ResourceKey=booleanToVisibilityConverter}}" IsEnabled="False" />

<Label Content="Test Results Format" Grid.Column="0" Grid.Row="8" VerticalAlignment="Top"/>
<ListBox ItemsSource="{Binding TestResultsFormatValues}" Grid.Column="1" Grid.Row="8" Grid.ColumnSpan="2" IsEnabled="{Binding Path=IncludeTests}" VerticalAlignment="Top">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding Path=Item}" GroupName="testResultsFormat" IsChecked="{Binding Path=IsSelected}"></RadioButton>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ComboBox ItemsSource="{Binding TestResultsFormatValues}" Grid.Column="1" Grid.Row="8" Grid.ColumnSpan="2" IsEnabled="{Binding Path=IncludeTests}" SelectedItem="{Binding SelectedTestResultsFormat}"></ComboBox>
<CheckBox Template="{StaticResource ResourceKey=myCheckBox}" Grid.Column="3" Grid.Row="8" IsChecked="{Binding Path=IsTestResultsFormatValid}" Visibility="{Binding Path=IncludeTests, Converter={StaticResource ResourceKey=booleanToVisibilityConverter}}" IsEnabled="False" />

<Label Content="Gherkin Language" Grid.Column="0" Grid.Row="9" VerticalAlignment="Top" />
Expand Down
47 changes: 22 additions & 25 deletions src/Pickles/Pickles.UserInterface/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class MainViewModel : ViewModelBase
{
private readonly MultiSelectableCollection<DocumentationFormat> documentationFormats;

private readonly SelectableCollection<TestResultsFormat> testResultsFormats;
private readonly TestResultsFormat[] testResultsFormats;

private readonly RelayCommand browseForFeatureFolderCommand;

Expand Down Expand Up @@ -107,6 +107,8 @@ public class MainViewModel : ViewModelBase

private bool isDocumentationFormatValid;

private TestResultsFormat selectedTestResultsFormat;

public MainViewModel(IMainModelSerializer mainModelSerializer, IFileSystem fileSystem)
{
this.documentationFormats =
Expand All @@ -115,11 +117,8 @@ public MainViewModel(IMainModelSerializer mainModelSerializer, IFileSystem fileS
this.documentationFormats.First().IsSelected = true;
this.documentationFormats.SelectionChanged += this.DocumentationFormatsOnCollectionChanged;

this.testResultsFormats =
new SelectableCollection<TestResultsFormat>(
Enum.GetValues(typeof(TestResultsFormat)).Cast<TestResultsFormat>());
this.testResultsFormats.First().IsSelected = true;
this.testResultsFormats.SelectionChanged += this.TestResultsFormatsOnCollectionChanged;
this.testResultsFormats = Enum.GetValues(typeof(TestResultsFormat)).Cast<TestResultsFormat>().ToArray();
this.selectedTestResultsFormat = TestResultsFormat.NUnit;

this.browseForFeatureFolderCommand = new RelayCommand(this.DoBrowseForFeature);
this.browseForOutputFolderCommand = new RelayCommand(this.DoBrowseForOutputFolder);
Expand Down Expand Up @@ -177,11 +176,17 @@ public string TestResultsFile
set { this.Set(() => this.TestResultsFile, ref this.testResultsFile, value); }
}

public SelectableCollection<TestResultsFormat> TestResultsFormatValues
public IEnumerable<TestResultsFormat> TestResultsFormatValues
{
get { return this.testResultsFormats; }
}

public TestResultsFormat SelectedTestResultsFormat
{
get { return this.selectedTestResultsFormat; }
set { this.Set(() => this.SelectedTestResultsFormat, ref this.selectedTestResultsFormat, value); }
}

public CultureInfo SelectedLanguage
{
get { return this.selectedLanguage; }
Expand Down Expand Up @@ -296,7 +301,7 @@ public void SaveToSettings()
ProjectVersion = this.projectVersion,
IncludeTestResults = this.includeTests,
TestResultsFile = this.testResultsFile,
TestResultsFormat = this.testResultsFormats.Selected,
TestResultsFormat = this.SelectedTestResultsFormat,
SelectedLanguageLcid = this.selectedLanguage.LCID,
DocumentationFormats =
this.documentationFormats.Where(item => item.IsSelected).Select(item => item.Item).ToArray(),
Expand All @@ -322,17 +327,8 @@ public void LoadFromSettings()
this.IncludeTests = mainModel.IncludeTestResults;
this.TestResultsFile = mainModel.TestResultsFile;

foreach (var item in this.TestResultsFormatValues)
{
if (item.Item == mainModel.TestResultsFormat)
{
item.IsSelected = true;
}
else
{
item.IsSelected = false;
}
}
this.SelectedTestResultsFormat =
this.testResultsFormats.Where(tf => tf == mainModel.TestResultsFormat).FirstOrDefault();

this.SelectedLanguage =
this.neutralCultures.Where(lv => lv.LCID == mainModel.SelectedLanguageLcid).FirstOrDefault();
Expand All @@ -345,11 +341,6 @@ public void LoadFromSettings()
this.CreateDirectoryForEachOutputFormat = mainModel.CreateDirectoryForEachOutputFormat;
}

private void TestResultsFormatsOnCollectionChanged(object sender, EventArgs notifyCollectionChangedEventArgs)
{
this.IsTestResultsFormatValid = Enum.IsDefined(typeof(TestResultsFormat), this.testResultsFormats.Selected);
}

private void DocumentationFormatsOnCollectionChanged(object sender, EventArgs notifyCollectionChangedEventArgs)
{
this.IsDocumentationFormatValid = this.documentationFormats.Selected.Any();
Expand Down Expand Up @@ -416,6 +407,12 @@ private void MainWindowViewModelPropertyChanged(object sender, PropertyChangedEv
break;
}

case "SelectedTestResultsFormat":
{
this.IsTestResultsFormatValid = Enum.IsDefined(typeof(TestResultsFormat), this.selectedTestResultsFormat);
break;
}

case "IsRunning":
case "IsFeatureDirectoryValid":
case "IsOutputDirectoryValid":
Expand Down Expand Up @@ -492,7 +489,7 @@ private void DoWork()
configuration.AddTestResultFiles(this.IncludeTests
? this.testResultsFile.Split(';').Select(trf => this.fileSystem.FileInfo.FromFileName(trf)).ToArray()
: null);
configuration.TestResultsFormat = this.testResultsFormats.Selected;
configuration.TestResultsFormat = this.selectedTestResultsFormat;
configuration.Language = this.selectedLanguage != null
? this.selectedLanguage.TwoLetterISOLanguageName
: CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
Expand Down

0 comments on commit 38f52d7

Please sign in to comment.