Skip to content

Commit

Permalink
Fixed up stylecop issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Terje Sandstrom committed Jan 21, 2020
1 parent 1daf1d6 commit c994fc8
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 38 deletions.
1 change: 1 addition & 0 deletions Osiris.Extended.ruleset
Expand Up @@ -55,5 +55,6 @@
<Rule Id="SA1623" Action="None" />
<Rule Id="SA1633" Action="None" />
<Rule Id="SA1649" Action="None" />
<Rule Id="SA0001" Action="None" />
</Rules>
</RuleSet>
Expand Up @@ -83,7 +83,7 @@ public class Case
}

[Test]
[TestCase("net48")] //test code requires ValueTuple support, so can't got to net35
[TestCase("net48")] // test code requires ValueTuple support, so can't got to net35
[TestCase("netcoreapp2.1")]
public static void Single_target_csproj(string targetFramework)
{
Expand Down
6 changes: 3 additions & 3 deletions src/NUnitTestAdapter/AdapterSettings.cs
Expand Up @@ -106,7 +106,7 @@ public enum VsTestCategoryType
public class AdapterSettings : IAdapterSettings
{
private const string RANDOM_SEED_FILE = "nunit_random_seed.tmp";
private TestLogger _logger;
private readonly TestLogger _logger;

#region Constructor

Expand Down Expand Up @@ -191,8 +191,8 @@ public AdapterSettings(TestLogger logger)
public string DomainUsage { get; private set; }

public bool ShowInternalProperties { get; private set; }
public bool UseParentFQNForParametrizedTests { get; private set; } // Default is false. True can fix certain test name patterns, but may have side effects.
public bool UseNUnitIdforTestCaseId { get; private set; } // default is false.
public bool UseParentFQNForParametrizedTests { get; private set; } // Default is false. True can fix certain test name patterns, but may have side effects.
public bool UseNUnitIdforTestCaseId { get; private set; } // default is false.


public VsTestCategoryType VsTestCategoryType { get; private set; } = VsTestCategoryType.NUnit;
Expand Down
6 changes: 3 additions & 3 deletions src/NUnitTestAdapter/NUnitTestFilterBuilder.cs
Expand Up @@ -30,7 +30,7 @@ namespace NUnit.VisualStudio.TestAdapter
{
public class NUnitTestFilterBuilder
{
private ITestFilterService _filterService;
private readonly ITestFilterService _filterService;

public static readonly TestFilter NoTestsFound = new TestFilter("<notestsfound/>");

Expand All @@ -43,13 +43,13 @@ public TestFilter ConvertTfsFilterToNUnitFilter(ITfsTestFilter tfsFilter, IList<
{
var filteredTestCases = tfsFilter.CheckFilter(loadedTestCases);
var testCases = filteredTestCases as TestCase[] ?? filteredTestCases.ToArray();
//TestLog.Info(string.Format("TFS Filter detected: LoadedTestCases {0}, Filtered Test Cases {1}", loadedTestCases.Count, testCases.Count()));
// TestLog.Info(string.Format("TFS Filter detected: LoadedTestCases {0}, Filtered Test Cases {1}", loadedTestCases.Count, testCases.Count()));
return testCases.Any() ? FilterByList(testCases) : NoTestsFound;
}

public TestFilter FilterByWhere(string where)
{
if (string.IsNullOrEmpty(where))
if (string.IsNullOrEmpty(where))
return TestFilter.Empty;
var filterBuilder = _filterService.GetTestFilterBuilder();
filterBuilder.SelectWhere(where);
Expand Down
32 changes: 14 additions & 18 deletions src/NUnitTestAdapter/TestConverter.cs
Expand Up @@ -154,6 +154,7 @@ public struct TestResultSet
#endregion

#region Helper Methods

/// <summary>
/// Makes a TestCase from an NUnit test, adding
/// navigation data if it can be found.
Expand Down Expand Up @@ -189,10 +190,9 @@ private TestCase MakeTestCaseFromXmlNode(XmlNode testNode)
{
fullyQualifiedName = parameterizedTestFullName;
}

}
}

var testCase = new TestCase(
fullyQualifiedName,
new Uri(NUnitTestAdapter.ExecutorUri),
Expand Down Expand Up @@ -305,8 +305,9 @@ private static void FillResultFromOutputNodes(IEnumerable<XmlNode> outputNodes,
: TestResultMessage.StandardOutCategory, output.InnerText));
}

bool IsErrorStream(string stream) => "error".Equals(stream, StringComparison.OrdinalIgnoreCase);
bool IsProgressStream(string stream) => "progress".Equals(stream, StringComparison.OrdinalIgnoreCase);
static bool IsErrorStream(string stream) => "error".Equals(stream, StringComparison.OrdinalIgnoreCase);

static bool IsProgressStream(string stream) => "progress".Equals(stream, StringComparison.OrdinalIgnoreCase);
}

/// <summary>
Expand Down Expand Up @@ -353,21 +354,16 @@ private AttachmentSet ParseAttachments(XmlNode resultNode)
// Public for testing
public static TestOutcome GetTestOutcome(XmlNode resultNode)
{
switch (resultNode.GetAttribute("result"))
return resultNode.GetAttribute("result") switch
{
case "Passed":
return TestOutcome.Passed;
case "Failed":
return TestOutcome.Failed;
case "Skipped":
return resultNode.GetAttribute("label") == "Ignored"
? TestOutcome.Skipped
: TestOutcome.None;
case "Warning":
return TestOutcome.Skipped;
default:
return TestOutcome.None;
}
"Passed" => TestOutcome.Passed,
"Failed" => TestOutcome.Failed,
"Skipped" => resultNode.GetAttribute("label") == "Ignored"
? TestOutcome.Skipped
: TestOutcome.None,
"Warning" => TestOutcome.Skipped,
_ => TestOutcome.None,
};
}

TestOutcome GetAssertionOutcome(XmlNode assertion)
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitTestAdapterTests/AdapterSettingsTests.cs
Expand Up @@ -365,7 +365,7 @@ public void LiveUnitTestingDataCollector()
Assert.That(_settings.NumberOfTestWorkers, Is.Zero);
Assert.True(_settings.InProcDataCollectorsAvailable);
}

[Test]
public void WhereCanBeSet()
{
Expand Down
1 change: 0 additions & 1 deletion src/NUnitTestAdapterTests/Fakes/FakeRunSettings.cs
Expand Up @@ -64,5 +64,4 @@ public FakeRunSettingsForWhere(string where)
}
public override string SettingsXml => $"<RunSettings><NUnit><Where>{_where}</Where></NUnit></RunSettings>";
}

}
Expand Up @@ -21,12 +21,11 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************


using System.Collections.Generic;
using NUnit.Framework;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using NSubstitute;
using NUnit.Engine;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using NUnit.Framework;

namespace NUnit.VisualStudio.TestAdapter.Tests.Filtering
{
Expand All @@ -52,7 +51,7 @@ public void ThatWhereFilterIsAdded()
var testFilterBuilder = Substitute.For<ITestFilterBuilder>();
filterService.GetTestFilterBuilder().Returns(testFilterBuilder);
sut.FilterByWhere(where);
testFilterBuilder.Received().SelectWhere(Arg.Is<string>(x=>x==where));
testFilterBuilder.Received().SelectWhere(Arg.Is<string>(x => x == where));
}
}
}
4 changes: 2 additions & 2 deletions src/NUnitTestAdapterTests/TestDiscoveryTests.cs
Expand Up @@ -90,8 +90,8 @@ public void VerifyTestCaseCount()
[TestCase("MockTest3", "NUnit.Tests.Assemblies.MockTestFixture.MockTest3")]
[TestCase("MockTest4", "NUnit.Tests.Assemblies.MockTestFixture.MockTest4")]
[TestCase("ExplicitlyRunTest", "NUnit.Tests.Assemblies.MockTestFixture.ExplicitlyRunTest")]
[TestCase("MethodWithParameters(9,11)", "NUnit.Tests.FixtureWithTestCases.MethodWithParameters",true)]
public void VerifyTestCaseIsFound(string name, string fullName,bool parentFQN = false)
[TestCase("MethodWithParameters(9,11)", "NUnit.Tests.FixtureWithTestCases.MethodWithParameters", true)]
public void VerifyTestCaseIsFound(string name, string fullName, bool parentFQN = false)
{
var testCase = testCases.Find(tc => tc.DisplayName == name);
Assert.That(testCase.FullyQualifiedName, Is.EqualTo(fullName));
Expand Down
8 changes: 3 additions & 5 deletions src/NUnitTestAdapterTests/TestExecutionTests.cs
Expand Up @@ -65,11 +65,11 @@ private int GetCount(TestOutcome outcome)
[Category("TestExecution")]
public class TestFilteringTests
{
private string MockAssemblyPath;
private string mockAssemblyPath;
[OneTimeSetUp]
public void LoadMockassembly()
{
MockAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "mock-assembly.dll");
mockAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "mock-assembly.dll");

// Sanity check to be sure we have the correct version of mock-assembly.dll
Assert.That(MockAssembly.TestsAtRuntime, Is.EqualTo(MockAssembly.Tests),
Expand All @@ -95,14 +95,12 @@ public void TestsWhereShouldFilter(string filter, int expectedCount)
var fakeFramework = new FakeFrameworkHandle();

var executor = TestAdapterUtils.CreateExecutor();
executor.RunTests(new[] { MockAssemblyPath }, context, fakeFramework);
executor.RunTests(new[] { mockAssemblyPath }, context, fakeFramework);

var completedRuns = fakeFramework.Events.Where(e => e.EventType == FakeFrameworkHandle.EventType.RecordEnd);

Assert.That(completedRuns, Has.Exactly(expectedCount).Items);

}

}

[Category("TestExecution")]
Expand Down

0 comments on commit c994fc8

Please sign in to comment.