Added more tests, code fixups.
This commit is contained in:
Родитель
1c471b7607
Коммит
7482d965cb
|
@ -1,10 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Osiris.Extended" ToolsVersion="11.0">
|
||||
<RuleSet Name="Osiris.Extended" ToolsVersion="15.0">
|
||||
<Include Path="basiccorrectnessrules.ruleset" Action="Default" />
|
||||
<Include Path="basicdesignguidelinerules.ruleset" Action="Default" />
|
||||
<Include Path="extendeddesignguidelinerules.ruleset" Action="Default" />
|
||||
<Include Path="globalizationrules.ruleset" Action="Default" />
|
||||
<Include Path="minimumrecommendedrules.ruleset" Action="Default" />
|
||||
<Rules AnalyzerId="CodeCracker.CSharp" RuleNamespace="CodeCracker.CSharp">
|
||||
<Rule Id="CC0001" Action="None" />
|
||||
<Rule Id="CC0097" Action="None" />
|
||||
<Rule Id="CC0105" Action="None" />
|
||||
</Rules>
|
||||
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
|
||||
<Rule Id="CA1062" Action="None" />
|
||||
<Rule Id="CA1704" Action="None" />
|
||||
|
|
|
@ -98,9 +98,9 @@ namespace NUnit.VisualStudio.TestAdapter.Dump
|
|||
|
||||
public void AddTestEvent(string text)
|
||||
{
|
||||
txt.Append("<NUnitTestEvent>");
|
||||
txt.Append("<NUnitTestEvent>\n");
|
||||
txt.Append(text);
|
||||
txt.Append("</NUnitTestEvent>");
|
||||
txt.Append("\n</NUnitTestEvent>\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,7 +126,7 @@ namespace NUnit.VisualStudio.TestAdapter.Dump
|
|||
twriter.Formatting = System.Xml.Formatting.Indented;
|
||||
twriter.Indentation = 3;
|
||||
twriter.QuoteChar = '\'';
|
||||
node.WriteContentTo(twriter);
|
||||
node.WriteTo(twriter);
|
||||
}
|
||||
return swriter.ToString();
|
||||
}
|
||||
|
|
|
@ -98,8 +98,7 @@ namespace NUnit.VisualStudio.TestAdapter
|
|||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_recorder.SendMessage(TestMessageLevel.Warning,
|
||||
string.Format("Error processing {0} event for {1}", node.Name, node.GetAttribute("fullname")));
|
||||
_recorder.SendMessage(TestMessageLevel.Warning,$"Error processing {node.Name} event for {node.GetAttribute("fullname")}");
|
||||
_recorder.SendMessage(TestMessageLevel.Warning, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace NUnit.VisualStudio.TestAdapter
|
|||
public TestCase ConvertTestCase(XmlNode testNode)
|
||||
{
|
||||
if (testNode == null || testNode.Name != "test-case")
|
||||
throw new ArgumentException("The argument must be a test case", "test");
|
||||
throw new ArgumentException("The argument must be a test case", nameof(testNode));
|
||||
|
||||
// Return cached value if we have one
|
||||
string id = testNode.GetAttribute("id");
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
// ***********************************************************************
|
||||
// Copyright (c) 2011-2017 Charlie Poole, Terje Sandstrom
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
|
||||
using NUnit.Framework;
|
||||
using NUnit.VisualStudio.TestAdapter.Tests.Fakes;
|
||||
|
@ -16,7 +34,9 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_settings = new AdapterSettings(new TestLogger(new MessageLoggerStub(), 0));
|
||||
var testlogger = new TestLogger(new MessageLoggerStub());
|
||||
_settings = new AdapterSettings(testlogger);
|
||||
testlogger.InitSettings(_settings);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
using System;
|
||||
// ***********************************************************************
|
||||
// Copyright (c) 2011-2015 Charlie Poole, Terje Sandstrom
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using NUnit.Framework;
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
using System.Text.RegularExpressions;
|
||||
// ***********************************************************************
|
||||
// Copyright (c) 2017 Charlie Poole, Terje Sandstrom
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
using System.Text.RegularExpressions;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using NUnit.VisualStudio.TestAdapter.Dump;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2012-2015 Charlie Poole, Terje Sandstrom
|
||||
// Copyright (c) 2012-2017 Charlie Poole, Terje Sandstrom
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
|
@ -148,7 +148,7 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
{
|
||||
testLog = new FakeFrameworkHandle();
|
||||
testConverter = new TestConverter(new TestLogger(new MessageLoggerStub()), FakeTestData.AssemblyPath, collectSourceInformation: true);
|
||||
MarshalByRefObject localInstance = (MarshalByRefObject)Activator.CreateInstance(typeof(NUnitEventListener), testLog, testConverter);
|
||||
var localInstance = (MarshalByRefObject)Activator.CreateInstance(typeof(NUnitEventListener), testLog, testConverter);
|
||||
|
||||
RemotingServices.Marshal(localInstance);
|
||||
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
using System.IO;
|
||||
// ***********************************************************************
|
||||
// Copyright (c) 2011-2017 Charlie Poole, Terje Sandstrom
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2012-2015 Charlie Poole, Terje Sandstrom
|
||||
// Copyright (c) 2012-2017 Charlie Poole, Terje Sandstrom
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
|
@ -143,7 +143,7 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
[TestCase("NotRunnableTest", TestOutcome.Failed, "No arguments were provided", false)]
|
||||
public void TestResultIsReportedCorrectly(string name, TestOutcome outcome, string message, bool hasStackTrace)
|
||||
{
|
||||
TestResult testResult = GetTestResult(name);
|
||||
var testResult = GetTestResult(name);
|
||||
|
||||
Assert.NotNull(testResult, "Unable to find result for method: " + name);
|
||||
Assert.That(testResult.Outcome, Is.EqualTo(outcome));
|
||||
|
@ -155,7 +155,7 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
[Test]
|
||||
public void AttachmentsShowSupportMultipleFiles()
|
||||
{
|
||||
TestResult test = GetTestResult(nameof(FixtureWithAttachment.AttachmentTest));
|
||||
var test = GetTestResult(nameof(FixtureWithAttachment.AttachmentTest));
|
||||
Assert.That(test, Is.Not.Null, "Could not find test result");
|
||||
|
||||
Assert.That(test.Attachments.Count, Is.EqualTo(1));
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
using System;
|
||||
// ***********************************************************************
|
||||
// Copyright (c) 2011-2017 Charlie Poole, Terje Sandstrom
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ using NUnit.Framework;
|
|||
|
||||
namespace NUnit.VisualStudio.TestAdapter.Tests
|
||||
{
|
||||
|
||||
|
||||
public class TestDataForTraits
|
||||
{
|
||||
#region TestXml Data
|
||||
|
@ -249,6 +249,107 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
</test-suite>
|
||||
</test-suite>";
|
||||
|
||||
///[Category("BaseClass")]
|
||||
///public class TestBase
|
||||
///{
|
||||
/// [Category("BaseMethod")]
|
||||
/// [Test]
|
||||
/// public void TestItBase()
|
||||
/// {
|
||||
/// Assert.That(true);
|
||||
/// }
|
||||
///}
|
||||
///[Category("DerivedClass")]
|
||||
///public class Derived : TestBase
|
||||
///{
|
||||
/// [Category("DerivedMethod")]
|
||||
/// [Test]
|
||||
/// public void TestItDerived()
|
||||
/// {
|
||||
/// Assert.That(true);
|
||||
/// }
|
||||
///}
|
||||
private const string TestCaseWithInheritedTestsInSameAssembly =
|
||||
@"<test-suite type='Assembly' id='0-1005' name='ClassLibrary11.dll' fullname='C:\Users\Terje\documents\visual studio 2017\Projects\ClassLibrary11\ClassLibrary11\bin\Debug\ClassLibrary11.dll' runstate='Runnable' testcasecount='3'>
|
||||
<properties>
|
||||
<property name='_PID' value='27456' />
|
||||
<property name='_APPDOMAIN' value='domain-aa3de7f5-ClassLibrary11.dll' />
|
||||
</properties>
|
||||
<test-suite type='TestSuite' id='0-1006' name='ClassLibrary11' fullname='ClassLibrary11' runstate='Runnable' testcasecount='3'>
|
||||
<test-suite type='TestFixture' id='0-1002' name='Derived' fullname='ClassLibrary11.Derived' classname='ClassLibrary11.Derived' runstate='Runnable' testcasecount='2'>
|
||||
<properties>
|
||||
<property name='Category' value='DerivedClass' />
|
||||
<property name='Category' value='BaseClass' />
|
||||
</properties>
|
||||
<test-case id='0-1004' name='TestItBase' fullname='ClassLibrary11.Derived.TestItBase' methodname='TestItBase' classname='ClassLibrary11.TestBase' runstate='Runnable' seed='1107082401'>
|
||||
<properties>
|
||||
<property name='Category' value='BaseMethod' />
|
||||
</properties>
|
||||
</test-case>
|
||||
<test-case id='0-1003' name='TestItDerived' fullname='ClassLibrary11.Derived.TestItDerived' methodname='TestItDerived' classname='ClassLibrary11.Derived' runstate='Runnable' seed='1484432600'>
|
||||
<properties>
|
||||
<property name='Category' value='DerivedMethod' />
|
||||
</properties>
|
||||
</test-case>
|
||||
</test-suite>
|
||||
<test-suite type='TestFixture' id='0-1000' name='TestBase' fullname='ClassLibrary11.TestBase' classname='ClassLibrary11.TestBase' runstate='Runnable' testcasecount='1'>
|
||||
<properties>
|
||||
<property name='Category' value='BaseClass' />
|
||||
</properties>
|
||||
<test-case id='0-1001' name='TestItBase' fullname='ClassLibrary11.TestBase.TestItBase' methodname='TestItBase' classname='ClassLibrary11.TestBase' runstate='Runnable' seed='144634857'>
|
||||
<properties>
|
||||
<property name='Category' value='BaseMethod' />
|
||||
</properties>
|
||||
</test-case>
|
||||
</test-suite>
|
||||
</test-suite>
|
||||
</test-suite>";
|
||||
|
||||
///[Category("BaseClass")]
|
||||
///public abstract class TestBase
|
||||
///{
|
||||
/// [Category("BaseMethod")]
|
||||
/// [Test]
|
||||
/// public void TestItBase()
|
||||
/// {
|
||||
/// Assert.That(true);
|
||||
/// }
|
||||
///}
|
||||
///[Category("DerivedClass")]
|
||||
///public class Derived : TestBase
|
||||
///{
|
||||
/// [Category("DerivedMethod")]
|
||||
/// [Test]
|
||||
/// public void TestItDerived()
|
||||
/// {
|
||||
/// Assert.That(true);
|
||||
/// }
|
||||
///}
|
||||
private const string TestCaseWithAbstractInheritedTestsInSameAssembly =
|
||||
@"<test-suite type='Assembly' id='0-1003' name='ClassLibrary11.dll' fullname='C:\Users\Terje\documents\visual studio 2017\Projects\ClassLibrary11\ClassLibrary11\bin\Debug\ClassLibrary11.dll' runstate='Runnable' testcasecount='2'>
|
||||
<properties>
|
||||
<property name='_PID' value='47684' />
|
||||
<property name='_APPDOMAIN' value='domain-aa3de7f5-ClassLibrary11.dll' />
|
||||
</properties>
|
||||
<test-suite type='TestSuite' id='0-1004' name='ClassLibrary11' fullname='ClassLibrary11' runstate='Runnable' testcasecount='2'>
|
||||
<test-suite type='TestFixture' id='0-1000' name='Derived' fullname='ClassLibrary11.Derived' classname='ClassLibrary11.Derived' runstate='Runnable' testcasecount='2'>
|
||||
<properties>
|
||||
<property name='Category' value='DerivedClass' />
|
||||
<property name='Category' value='BaseClass' />
|
||||
</properties>
|
||||
<test-case id='0-1002' name='TestItBase' fullname='ClassLibrary11.Derived.TestItBase' methodname='TestItBase' classname='ClassLibrary11.TestBase' runstate='Runnable' seed='1628925226'>
|
||||
<properties>
|
||||
<property name='Category' value='BaseMethod' />
|
||||
</properties>
|
||||
</test-case>
|
||||
<test-case id='0-1001' name='TestItDerived' fullname='ClassLibrary11.Derived.TestItDerived' methodname='TestItDerived' classname='ClassLibrary11.Derived' runstate='Runnable' seed='1596181992'>
|
||||
<properties>
|
||||
<property name='Category' value='DerivedMethod' />
|
||||
</properties>
|
||||
</test-case>
|
||||
</test-suite>
|
||||
</test-suite>
|
||||
</test-suite>";
|
||||
|
||||
|
||||
#endregion
|
||||
|
@ -259,6 +360,10 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
public XmlNode XmlForStandardTest => XmlHelper.CreateXmlNode(TestXmlStandardClass);
|
||||
|
||||
public XmlNode XmlForTestCaseWithCategory => XmlHelper.CreateXmlNode(TestCaseWithCategory);
|
||||
|
||||
public XmlNode XmlForTestCaseWithInheritedTestsInSameAssembly => XmlHelper.CreateXmlNode(TestCaseWithInheritedTestsInSameAssembly);
|
||||
public XmlNode XmlForTestCaseWithAbstractInheritedTestsInSameAssembly => XmlHelper.CreateXmlNode(TestCaseWithAbstractInheritedTestsInSameAssembly);
|
||||
|
||||
}
|
||||
|
||||
#if !NETCOREAPP1_0
|
||||
|
@ -276,7 +381,10 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
{
|
||||
testDataForTraits = new TestDataForTraits();
|
||||
var messagelogger = Substitute.For<IMessageLogger>();
|
||||
var testlogger = new TestLogger(messagelogger, 5);
|
||||
var adaptersettings = Substitute.For<IAdapterSettings>();
|
||||
adaptersettings.Verbosity.Returns(5);
|
||||
var testlogger = new TestLogger(messagelogger);
|
||||
testlogger.InitSettings(adaptersettings);
|
||||
|
||||
testconverter = new TestConverter(testlogger, "whatever", false);
|
||||
testcaselist = new List<TestCase>();
|
||||
|
@ -326,6 +434,53 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
Assert.That(testcase1.Traits.Count(), Is.EqualTo(2), "Wrong number of categories for derived test case");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ThatInheritedConcreteClassesHaveTraits()
|
||||
{
|
||||
var xml = testDataForTraits.XmlForTestCaseWithInheritedTestsInSameAssembly;
|
||||
ProcessXml2TestCase(xml);
|
||||
Assert.That(testcaselist.Count, Is.EqualTo(3), "Wrong number of testcases found");
|
||||
var uniqueTraits = UniqueTraits();
|
||||
Assert.That(uniqueTraits.Count(),Is.EqualTo(4),"Wrong number of traits");
|
||||
string searchTrait = "BaseClass";
|
||||
var tcWithTrait = TcWithTrait(searchTrait);
|
||||
Assert.That(tcWithTrait.Count(),Is.EqualTo(3),$"Wrong number of testcases found for trait={searchTrait}");
|
||||
|
||||
}
|
||||
|
||||
private IEnumerable<TestCase> TcWithTrait(string searchTrait)
|
||||
{
|
||||
return testcaselist.Where(o => o.Traits.Select(t => t.Value).Contains(searchTrait));
|
||||
}
|
||||
|
||||
private IEnumerable<string> UniqueTraits()
|
||||
{
|
||||
var traits = new List<string>();
|
||||
foreach (var tc in testcaselist)
|
||||
{
|
||||
traits.AddRange(tc.Traits.Select(o => o.Value));
|
||||
}
|
||||
var uniqueTraits = traits.Distinct();
|
||||
return uniqueTraits;
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ThatInheritedAbstractClassesHaveTraits()
|
||||
{
|
||||
var xml = testDataForTraits.XmlForTestCaseWithAbstractInheritedTestsInSameAssembly;
|
||||
ProcessXml2TestCase(xml);
|
||||
Assert.That(testcaselist.Count, Is.EqualTo(2), "Wrong number of testcases found");
|
||||
var uniqueTraits = UniqueTraits();
|
||||
Assert.That(uniqueTraits.Count(), Is.EqualTo(4), "Wrong number of traits");
|
||||
string searchTrait = "BaseClass";
|
||||
var tcWithTrait = TcWithTrait(searchTrait);
|
||||
Assert.That(tcWithTrait.Count(), Is.EqualTo(2), $"Wrong number of testcases found for trait={searchTrait}");
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ProcessXml2TestCase(XmlNode xml)
|
||||
{
|
||||
foreach (XmlNode node in xml.SelectNodes("//test-case"))
|
||||
|
@ -358,12 +513,12 @@ namespace NUnit.VisualStudio.TestAdapter.Tests
|
|||
ProcessXml2TestCase(xml);
|
||||
|
||||
Assert.That(testcaselist.Count, Is.EqualTo(3), "Wrong number of testcases found");
|
||||
var testcasesWithCategories = testcaselist.Where(o => o.Traits?.FirstOrDefault(p=>p.Name=="Category")!= null);
|
||||
var testcasesWithCategories = testcaselist.Where(o => o.Traits?.FirstOrDefault(p => p.Name == "Category") != null);
|
||||
Assert.That(testcasesWithCategories, Is.Not.Null, "Didn't find the testcases");
|
||||
Assert.That(testcasesWithCategories.Count(),Is.EqualTo(1),"Wrong number of testcases with categories, should be only 1");
|
||||
Assert.That(testcasesWithCategories.Count(), Is.EqualTo(1), "Wrong number of testcases with categories, should be only 1");
|
||||
var tc = testcasesWithCategories.FirstOrDefault();
|
||||
Assert.That(tc.Traits.Count(), Is.EqualTo(1), "Wrong number of categories for test case");
|
||||
Assert.That(tc.Traits.First().Value,Is.EqualTo("Single"));
|
||||
Assert.That(tc.Traits.First().Value, Is.EqualTo("Single"));
|
||||
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче