Skip to content

Commit 34b37ed

Browse files
committed
Merge pull request #1109 from Hosch250/BugBlipper
Add new tests, correct a couple tests, fix bug in grouping grid
2 parents a456c2d + 42aa4c9 commit 34b37ed

12 files changed

+502
-76
lines changed

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@
582582
<DependentUpon>SettingsForm.cs</DependentUpon>
583583
</Compile>
584584
<Compile Include="UI\Settings\SettingsControlViewModel.cs" />
585+
<Compile Include="UI\Settings\SettingsView.cs" />
585586
<Compile Include="UI\Settings\SettingsViews.cs" />
586587
<Compile Include="UI\Settings\Converters\SettingsViewToPageConverter.cs" />
587588
<Compile Include="UI\Settings\TodoSettings.xaml.cs">

RetailCoder.VBE/Settings/CodeInspectionSettings.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,26 @@ public CodeInspectionSetting(string name, string description, CodeInspectionType
9191
public CodeInspectionSetting(IInspectionModel inspection)
9292
: this(inspection.Name, inspection.Description, inspection.InspectionType, inspection.DefaultSeverity, inspection.Severity)
9393
{ }
94+
95+
public override bool Equals(object obj)
96+
{
97+
var inspectionSetting = obj as CodeInspectionSetting;
98+
99+
return inspectionSetting != null &&
100+
inspectionSetting.InspectionType == InspectionType &&
101+
inspectionSetting.Name == Name &&
102+
inspectionSetting.Severity == Severity;
103+
}
104+
105+
public override int GetHashCode()
106+
{
107+
unchecked
108+
{
109+
var hashCode = (Name != null ? Name.GetHashCode() : 0);
110+
hashCode = (hashCode * 397) ^ (int) Severity;
111+
hashCode = (hashCode * 397) ^ (int) InspectionType;
112+
return hashCode;
113+
}
114+
}
94115
}
95116
}

RetailCoder.VBE/Settings/Hotkey.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,26 @@ public string Prompt
1414
{
1515
get { return RubberduckUI.ResourceManager.GetString(Name + "Hotkey_Description"); }
1616
}
17+
18+
public override bool Equals(object obj)
19+
{
20+
var hotkey = obj as Hotkey;
21+
22+
return hotkey != null &&
23+
hotkey.Name == Name &&
24+
hotkey.KeyDisplaySymbol == KeyDisplaySymbol &&
25+
hotkey.IsEnabled == IsEnabled;
26+
}
27+
28+
public override int GetHashCode()
29+
{
30+
unchecked
31+
{
32+
var hashCode = (Name != null ? Name.GetHashCode() : 0);
33+
hashCode = (hashCode * 397) ^ (KeyDisplaySymbol != null ? KeyDisplaySymbol.GetHashCode() : 0);
34+
hashCode = (hashCode * 397) ^ IsEnabled.GetHashCode();
35+
return hashCode;
36+
}
37+
}
1738
}
1839
}

RetailCoder.VBE/UI/Controls/GroupingGrid.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
108108
<Setter Property="ItemContainerStyle" Value="{StaticResource PrettifyRow}" />
109109
<Setter Property="ColumnHeaderHeight" Value="22" />
110+
<Setter Property="SelectionMode" Value="Single" />
110111
</Style>
111112
</DataGrid.Style>
112113
<DataGrid.CellStyle>

RetailCoder.VBE/UI/Settings/SettingsControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<Border Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Height="40" VerticalAlignment="Bottom" BorderBrush="Black" BorderThickness="0, 1, 0, 0">
7070
<DockPanel VerticalAlignment="Center" Height="40" Background="{x:Static SystemColors.ControlDarkBrush}">
7171
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
72-
<Button Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Settings_ResetSettings}" MinWidth="75" Height="20" HorizontalAlignment="Right" Margin="20,0" Command="{Binding RefreshButtonCommand}" />
72+
<Button Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Settings_ResetSettings}" MinWidth="75" Height="20" HorizontalAlignment="Right" Margin="20,0" Command="{Binding ResetButtonCommand}" />
7373
<Button Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=OK}" MinWidth="75" Height="20" HorizontalAlignment="Left" Margin="5, 0" Command="{Binding OKButtonCommand}" />
7474
<Button Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CancelButtonText}" MinWidth="75" Height="20" HorizontalAlignment="Right" Margin="5, 0, 10, 0" Command="{Binding CancelButtonCommand}" />
7575
</StackPanel>

RetailCoder.VBE/UI/Settings/SettingsControlViewModel.cs

Lines changed: 16 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,29 @@
77

88
namespace Rubberduck.UI.Settings
99
{
10-
public class SettingsView
11-
{
12-
public string Label { get { return RubberduckUI.ResourceManager.GetString("SettingsCaption_" + View); } }
13-
public string Instructions
14-
{
15-
get
16-
{
17-
return RubberduckUI.ResourceManager.GetString("SettingsInstructions_" + View);
18-
}
19-
}
20-
public ISettingsView Control { get; set; }
21-
public SettingsViews View { get; set; }
22-
}
23-
2410
public class SettingsControlViewModel : ViewModelBase
2511
{
2612
private readonly IGeneralConfigService _configService;
2713
private readonly Configuration _config;
2814

29-
public SettingsControlViewModel(IGeneralConfigService configService, SettingsViews view = Settings.SettingsViews.GeneralSettings)
15+
public SettingsControlViewModel(IGeneralConfigService configService,
16+
Configuration config,
17+
SettingsView generalSettings,
18+
SettingsView todoSettings,
19+
SettingsView inspectionSettings,
20+
SettingsView unitTestSettings,
21+
SettingsView indenterSettings,
22+
SettingsViews activeView = Settings.SettingsViews.GeneralSettings)
3023
{
3124
_configService = configService;
32-
_config = configService.LoadConfiguration();
25+
_config = config;
3326

3427
SettingsViews = new ObservableCollection<SettingsView>
3528
{
36-
new SettingsView
37-
{
38-
Control = new GeneralSettings(new GeneralSettingsViewModel(_config)),
39-
View = Settings.SettingsViews.GeneralSettings
40-
},
41-
new SettingsView
42-
{
43-
Control = new TodoSettings(new TodoSettingsViewModel(_config)),
44-
View = Settings.SettingsViews.TodoSettings
45-
},
46-
new SettingsView
47-
{
48-
Control = new InspectionSettings(new InspectionSettingsViewModel(_config)),
49-
View = Settings.SettingsViews.InspectionSettings
50-
},
51-
new SettingsView
52-
{
53-
Control = new UnitTestSettings(new UnitTestSettingsViewModel(_config)),
54-
View = Settings.SettingsViews.UnitTestSettings
55-
},
56-
new SettingsView
57-
{
58-
Control = new IndenterSettings(new IndenterSettingsViewModel(_config)),
59-
View = Settings.SettingsViews.IndenterSettings
60-
}
29+
generalSettings, todoSettings, inspectionSettings, unitTestSettings, indenterSettings
6130
};
6231

63-
SelectedSettingsView = SettingsViews.First(v => v.View == view);
32+
SelectedSettingsView = SettingsViews.First(v => v.View == activeView);
6433
}
6534

6635
private ObservableCollection<SettingsView> _settingsViews;
@@ -153,16 +122,16 @@ public ICommand CancelButtonCommand
153122
}
154123
}
155124

156-
private ICommand _refreshButtonCommand;
157-
public ICommand RefreshButtonCommand
125+
private ICommand _resetButtonCommand;
126+
public ICommand ResetButtonCommand
158127
{
159128
get
160129
{
161-
if (_refreshButtonCommand != null)
130+
if (_resetButtonCommand != null)
162131
{
163-
return _refreshButtonCommand;
132+
return _resetButtonCommand;
164133
}
165-
return _refreshButtonCommand = new DelegateCommand(_ =>
134+
return _resetButtonCommand = new DelegateCommand(_ =>
166135
{
167136
var defaultConfig = _configService.GetDefaultConfiguration();
168137
foreach (var vm in SettingsViews.Select(v => v.Control.ViewModel))

RetailCoder.VBE/UI/Settings/SettingsForm.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,42 @@ namespace Rubberduck.UI.Settings
55
{
66
public partial class SettingsForm : Form
77
{
8-
private readonly IGeneralConfigService _configService;
9-
108
public SettingsForm()
119
{
1210
InitializeComponent();
1311
}
1412

1513
public SettingsForm(IGeneralConfigService configService) : this()
1614
{
17-
_configService = configService;
15+
var config = configService.LoadConfiguration();
1816

19-
ViewModel = new SettingsControlViewModel(_configService);
17+
ViewModel = new SettingsControlViewModel(configService,
18+
config,
19+
new SettingsView
20+
{
21+
Control = new GeneralSettings(new GeneralSettingsViewModel(config)),
22+
View = SettingsViews.GeneralSettings
23+
},
24+
new SettingsView
25+
{
26+
Control = new TodoSettings(new TodoSettingsViewModel(config)),
27+
View = SettingsViews.TodoSettings
28+
},
29+
new SettingsView
30+
{
31+
Control = new InspectionSettings(new InspectionSettingsViewModel(config)),
32+
View = SettingsViews.InspectionSettings
33+
},
34+
new SettingsView
35+
{
36+
Control = new UnitTestSettings(new UnitTestSettingsViewModel(config)),
37+
View = SettingsViews.UnitTestSettings
38+
},
39+
new SettingsView
40+
{
41+
Control = new IndenterSettings(new IndenterSettingsViewModel(config)),
42+
View = SettingsViews.IndenterSettings
43+
});
2044

2145
ViewModel.OnOKButtonClicked += ViewModel_OnOKButtonClicked;
2246
ViewModel.OnCancelButtonClicked += ViewModel_OnCancelButtonClicked;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Rubberduck.UI.Settings
2+
{
3+
public class SettingsView
4+
{
5+
public string Label { get { return RubberduckUI.ResourceManager.GetString("SettingsCaption_" + View); } }
6+
public string Instructions
7+
{
8+
get
9+
{
10+
return RubberduckUI.ResourceManager.GetString("SettingsInstructions_" + View);
11+
}
12+
}
13+
public ISettingsView Control { get; set; }
14+
public SettingsViews View { get; set; }
15+
}
16+
}

RubberduckTests/RubberduckTests.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@
5757
<Reference Include="Moq">
5858
<HintPath>..\packages\Moq.4.2.1507.0118\lib\net40\Moq.dll</HintPath>
5959
</Reference>
60+
<Reference Include="PresentationCore" />
6061
<Reference Include="PresentationFramework" />
6162
<Reference Include="System" />
6263
<Reference Include="System.Windows.Forms" />
64+
<Reference Include="System.Xaml" />
6365
<Reference Include="WindowsBase" />
6466
</ItemGroup>
6567
<Choose>
@@ -119,7 +121,7 @@
119121
<Compile Include="Refactoring\RenameTests.cs" />
120122
<Compile Include="Refactoring\ReorderParametersTests.cs" />
121123
<Compile Include="RubberduckParserTests.cs" />
122-
<Compile Include="Settings\CodeInspectionSettingsTests.cs" />
124+
<Compile Include="Settings\InspectionSettingsTests.cs" />
123125
<Compile Include="Settings\GeneralSettingsTests.cs" />
124126
<Compile Include="Settings\IndenterSettingsTests.cs" />
125127
<Compile Include="Settings\SettingsControlTests.cs" />

RubberduckTests/Settings/CodeInspectionSettingsTests.cs renamed to RubberduckTests/Settings/InspectionSettingsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace RubberduckTests.Settings
88
{
99
[TestClass]
10-
public class CodeInspectionSettingsTests
10+
public class InspectionSettingsTests
1111
{
1212
private Configuration GetDefaultConfig()
1313
{

0 commit comments

Comments
 (0)