-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #791 from nunit/RemoveDuplicates
Remove duplicates
- Loading branch information
Showing
7 changed files
with
134 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
src/NUnitTestAdapterTests/NUnitEventListenerOutputTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; | ||
using NSubstitute; | ||
using NUnit.Framework; | ||
using NUnit.VisualStudio.TestAdapter.Dump; | ||
using NUnit.VisualStudio.TestAdapter.NUnitEngine; | ||
|
||
namespace NUnit.VisualStudio.TestAdapter.Tests | ||
{ | ||
/// <summary> | ||
/// These tests ensure correct console output, which is what we send to the "recorder". | ||
/// </summary> | ||
public class NUnitEventListenerOutputTests | ||
{ | ||
private ITestExecutionRecorder recorder; | ||
private ITestConverterCommon converter; | ||
private IDumpXml dumpxml; | ||
private IAdapterSettings settings; | ||
private INUnit3TestExecutor executor; | ||
|
||
|
||
private const string TestOutputProgress = | ||
@"<test-output stream='Progress' testid='0-1001' testname='Something.TestClass.Whatever'><![CDATA[Whatever | ||
]]></test-output>"; | ||
|
||
private const string TestOutputOut = | ||
@"<test-output stream='Out' testid='0-1001' testname='Something.TestClass.Whatever'><![CDATA[Whatever | ||
]]></test-output>"; | ||
|
||
private const string TestOutputError = | ||
@"<test-output stream='Error' testid='0-1001' testname='Something.TestClass.Whatever'><![CDATA[Whatever | ||
]]></test-output>"; | ||
|
||
private const string BlankTestOutput = | ||
@"<test-output stream='Progress' testid='0-1001' testname='Something.TestClass.Whatever'><![CDATA[ ]]></test-output>"; | ||
|
||
private const string TestFinish = | ||
@"<test-case id='0-1001' name='Test1' fullname='UnitTests.Test1' methodname='Test1' classname='UnitTests' runstate='Runnable' seed='108294034' result='Passed' start-time='2018-10-15 09:41:24Z' end-time='2018-10-15 09:41:24Z' duration='0.000203' asserts='0' parentId='0-1000' />"; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
recorder = Substitute.For<IFrameworkHandle>(); | ||
converter = Substitute.For<ITestConverterCommon>(); | ||
dumpxml = Substitute.For<IDumpXml>(); | ||
settings = Substitute.For<IAdapterSettings>(); | ||
executor = Substitute.For<INUnit3TestExecutor>(); | ||
executor.Settings.Returns(settings); | ||
executor.FrameworkHandle.Returns(recorder); | ||
} | ||
|
||
[Test] | ||
public void ThatNormalTestOutputIsOutput() | ||
{ | ||
var sut = new NUnitEventListener(converter, executor); | ||
sut.OnTestEvent(TestOutputProgress); | ||
sut.OnTestEvent(TestFinish); | ||
|
||
recorder.Received().SendMessage(Arg.Any<TestMessageLevel>(), Arg.Is<string>(x => x.StartsWith("Whatever"))); | ||
converter.Received().GetVsTestResults(Arg.Any<NUnitTestEventTestCase>(), Arg.Is<ICollection<INUnitTestEventTestOutput>>(x => x.Count == 1)); | ||
} | ||
|
||
[Test] | ||
public void ThatNormalTestOutputIsError() | ||
{ | ||
var sut = new NUnitEventListener(converter, executor); | ||
sut.OnTestEvent(TestOutputError); | ||
sut.OnTestEvent(TestFinish); | ||
|
||
recorder.Received().SendMessage(Arg.Any<TestMessageLevel>(), Arg.Is<string>(x => x.StartsWith("Whatever"))); | ||
converter.Received().GetVsTestResults(Arg.Any<NUnitTestEventTestCase>(), Arg.Is<ICollection<INUnitTestEventTestOutput>>(x => x.Count == 1)); | ||
} | ||
|
||
[Test] | ||
public void ThatTestOutputWithOnlyWhiteSpaceIsNotOutput() | ||
{ | ||
var sut = new NUnitEventListener(converter, executor); | ||
|
||
sut.OnTestEvent(BlankTestOutput); | ||
|
||
recorder.DidNotReceive().SendMessage(Arg.Any<TestMessageLevel>(), Arg.Any<string>()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters