Skip to content

Commit

Permalink
Added per solution settings
Browse files Browse the repository at this point in the history
  • Loading branch information
axodox committed Mar 15, 2017
1 parent 5868f3f commit 59ceed4
Show file tree
Hide file tree
Showing 31 changed files with 629 additions and 602 deletions.
5 changes: 3 additions & 2 deletions AxoCover.Runner/TestDiscoveryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.ServiceModel;
Expand Down Expand Up @@ -85,14 +86,14 @@ private void DiscoverTests(string[] adapterSources, IEnumerable<string> testSour
}

_monitor.RecordMessage(TestMessageLevel.Informational, $"Discovering tests...");
if (runSettingsPath != null)
if (!string.IsNullOrEmpty(runSettingsPath))
{
_monitor.RecordMessage(TestMessageLevel.Informational, $"Using run settings {runSettingsPath}.");
}

try
{
var runSettings = new RunSettings(runSettingsPath == null ? null : File.ReadAllText(runSettingsPath));
var runSettings = new RunSettings(string.IsNullOrEmpty(runSettingsPath) ? null : File.ReadAllText(runSettingsPath));
var context = new TestDiscoveryContext(_monitor, runSettings);

foreach (var testDiscoverer in _testDiscoverers)
Expand Down
2 changes: 1 addition & 1 deletion AxoCover.Runner/TestExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public TestExecutionContext(ITestExecutionMonitor monitor, TestExecutionOptions
{
_monitor = monitor;
_options = options;
_runSettings = new RunSettings(options.RunSettingsPath == null ? null : File.ReadAllText(options.RunSettingsPath));
_runSettings = new RunSettings(string.IsNullOrEmpty(options.RunSettingsPath) ? null : File.ReadAllText(options.RunSettingsPath));
}

class EmptyTestCaseFilterExpression : ITestCaseFilterExpression
Expand Down
2 changes: 1 addition & 1 deletion AxoCover.Runner/TestExecutionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void RunTests(IEnumerable<TestCase> testCases, TestExecutionOptions opti
}

_monitor.RecordMessage(TestMessageLevel.Informational, $"Executing tests...");
if (options.RunSettingsPath != null)
if (!string.IsNullOrEmpty(options.RunSettingsPath))
{
_monitor.RecordMessage(TestMessageLevel.Informational, $"Using run settings {options.RunSettingsPath}.");
}
Expand Down
10 changes: 9 additions & 1 deletion AxoCover/AxoCover.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel">
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.11.0.0\lib\net35\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\VSSDK.Text.11.0.4\lib\net45\Microsoft.VisualStudio.Text.Data.dll</HintPath>
Expand Down Expand Up @@ -187,6 +187,10 @@
<Private>True</Private>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationFramework.Aero" />
<Reference Include="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>False</EmbedInteropTypes>
Expand Down Expand Up @@ -266,6 +270,7 @@
<Compile Include="Converters\BooleanInverter.cs" />
<Compile Include="Converters\BooleanToOpacityConverter.cs" />
<Compile Include="Converters\CoveragePercentageToBrushConverter.cs" />
<Compile Include="Converters\EmptyToBooleanConverter.cs" />
<Compile Include="Converters\EnumToValuesConverter.cs" />
<Compile Include="Converters\InvertedBooleanToVisibilityConverter.cs" />
<Compile Include="Converters\NotNullToBooleanConverter.cs" />
Expand All @@ -288,6 +293,7 @@
<Compile Include="Models\Data\CoverageReport\FileRef.cs" />
<Compile Include="Models\Data\CoverageReport\TrackedMethod.cs" />
<Compile Include="Models\Data\CoverageReport\TrackedMethodRef.cs" />
<Compile Include="Models\Data\OpenCoverOptions.cs" />
<Compile Include="Models\Data\TestResults.cs" />
<Compile Include="Models\DiscoveryProcess.cs" />
<Compile Include="Models\ExecutionProcess.cs" />
Expand Down Expand Up @@ -319,10 +325,12 @@
<Compile Include="Models\ICoverageProvider.cs" />
<Compile Include="Models\IEditorContext.cs" />
<Compile Include="Models\IMultiplexer.cs" />
<Compile Include="Models\IOptions.cs" />
<Compile Include="Models\IReportProvider.cs" />
<Compile Include="Models\IResultProvider.cs" />
<Compile Include="Models\ITelemetryManager.cs" />
<Compile Include="Models\IStorageController.cs" />
<Compile Include="Models\Options.cs" />
<Compile Include="Models\TestCaseProcessors\ITestCaseProcessor.cs" />
<Compile Include="Models\ITestProvider.cs" />
<Compile Include="Models\EditorContext.cs" />
Expand Down
19 changes: 7 additions & 12 deletions AxoCover/AxoCoverPackage.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using AxoCover.Models;
using AxoCover.Properties;
using AxoCover.Views;
using Microsoft.Practices.Unity;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -35,16 +34,17 @@ static AxoCoverPackage()
Manifest = PackageManifest.FromFile(Path.Combine(PackageRoot, "extension.vsixmanifest"));
}

private readonly IOptions _options;

public AxoCoverPackage()
{
Settings.Default.PropertyChanged += OnSettingChanged;
ContainerProvider.Initialize();
_options = ContainerProvider.Container.Resolve<IOptions>();
Application.Current.Dispatcher.BeginInvoke(new Action(InitializeTelemetry), DispatcherPriority.ApplicationIdle);
}

private static void InitializeTelemetry()
private void InitializeTelemetry()
{
if (!Settings.Default.IsTelemetryModeSelected)
if (!_options.IsTelemetryModeSelected)
{
var dialog = new ViewDialog<TelemetryIntroductionView>()
{
Expand All @@ -53,16 +53,11 @@ private static void InitializeTelemetry()

if (dialog.ShowDialog() == true)
{
Settings.Default.IsTelemetryModeSelected = true;
_options.IsTelemetryModeSelected = true;
}
}
}

private void OnSettingChanged(object sender, PropertyChangedEventArgs e)
{
Settings.Default.Save();
}

protected override void Initialize()
{
base.Initialize();
Expand Down
19 changes: 19 additions & 0 deletions AxoCover/Converters/EmptyToBooleanConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace AxoCover.Converters
{
public class EmptyToBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return string.IsNullOrEmpty(value as string);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}
Loading

0 comments on commit 59ceed4

Please sign in to comment.