diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1
index a0caf01eb..2c92b8f5f 100644
--- a/PowerShellEditorServices.build.ps1
+++ b/PowerShellEditorServices.build.ps1
@@ -50,7 +50,7 @@ function Invoke-WithCreateDefaultHook {
}
}
-task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestE2E {
+task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestE2E {
$dotnetPath = "$PSScriptRoot/.dotnet"
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" }
@@ -241,8 +241,7 @@ function DotNetTestFilter {
if ($TestFilter) { @("--filter",$TestFilter) } else { "" }
}
-# task Test TestServer,TestProtocol,TestE2E
-task Test TestE2E
+task Test TestServer,TestE2E
task TestServer {
Set-Location .\test\PowerShellEditorServices.Test\
@@ -256,18 +255,6 @@ task TestServer {
}
}
-task TestProtocol {
- Set-Location .\test\PowerShellEditorServices.Test.Protocol\
-
- if (-not $script:IsUnix) {
- exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) }
- }
-
- Invoke-WithCreateDefaultHook {
- exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Core (DotNetTestFilter) }
- }
-}
-
task TestHost {
Set-Location .\test\PowerShellEditorServices.Test.Host\
diff --git a/PowerShellEditorServices.sln b/PowerShellEditorServices.sln
index 802579fef..38106c3a0 100644
--- a/PowerShellEditorServices.sln
+++ b/PowerShellEditorServices.sln
@@ -18,8 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{E231
scripts\AddCopyrightHeaders.ps1 = scripts\AddCopyrightHeaders.ps1
EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test.Protocol", "test\PowerShellEditorServices.Test.Protocol\PowerShellEditorServices.Test.Protocol.csproj", "{E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.VSCode", "src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj", "{3B38E8DA-8BFF-4264-AF16-47929E6398A3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices", "src\PowerShellEditorServices\PowerShellEditorServices.csproj", "{29EEDF03-0990-45F4-846E-2616970D1FA2}"
@@ -95,24 +93,6 @@ Global
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x64.Build.0 = Release|Any CPU
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x86.ActiveCfg = Release|Any CPU
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x86.Build.0 = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|Any CPU.Build.0 = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|x64.ActiveCfg = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|x64.Build.0 = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|x86.ActiveCfg = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.CoreCLR|x86.Build.0 = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|x64.ActiveCfg = Debug|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|x64.Build.0 = Debug|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|x86.ActiveCfg = Debug|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Debug|x86.Build.0 = Debug|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|Any CPU.Build.0 = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|x64.ActiveCfg = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|x64.Build.0 = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|x86.ActiveCfg = Release|Any CPU
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4}.Release|x86.Build.0 = Release|Any CPU
{3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|Any CPU.ActiveCfg = CoreCLR|Any CPU
{3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|Any CPU.Build.0 = CoreCLR|Any CPU
{3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|x64.ActiveCfg = CoreCLR|Any CPU
@@ -193,7 +173,6 @@ Global
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
- {E3A5CF5D-6E41-44AC-AE0A-4C227E4BACD4} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
{3B38E8DA-8BFF-4264-AF16-47929E6398A3} = {F594E7FD-1E72-4E51-A496-B019C2BA3180}
{29EEDF03-0990-45F4-846E-2616970D1FA2} = {F594E7FD-1E72-4E51-A496-B019C2BA3180}
{2561F253-8F72-436A-BCC3-AA63AB82EDC0} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj
index 077a37eb7..d3d4a2536 100644
--- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj
+++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj
@@ -24,6 +24,12 @@
<_Parameter1>Microsoft.PowerShell.EditorServices.Hosting
+
+ <_Parameter1>Microsoft.PowerShell.EditorServices.Test
+
+
+ <_Parameter1>Microsoft.PowerShell.EditorServices.Test.Shared
+
diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/Console/ChoicePromptHandler.cs b/src/PowerShellEditorServices/Services/PowerShellContext/Console/ChoicePromptHandler.cs
index d03facc8a..81b4b5a24 100644
--- a/src/PowerShellEditorServices/Services/PowerShellContext/Console/ChoicePromptHandler.cs
+++ b/src/PowerShellEditorServices/Services/PowerShellContext/Console/ChoicePromptHandler.cs
@@ -146,7 +146,7 @@ public Task PromptForChoiceAsync(
throw new TaskCanceledException(task);
}
- return this.GetSingleResult(task.Result);
+ return this.GetSingleResult(task.GetAwaiter().GetResult());
}));
}
@@ -205,7 +205,7 @@ private async Task WaitForTaskAsync(Task taskToWait)
throw new PipelineStoppedException();
}
- return taskToWait.Result;
+ return await taskToWait.ConfigureAwait(false);
}
private async Task StartPromptLoopAsync(
diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs
index 13d152e79..efe33f120 100644
--- a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs
+++ b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs
@@ -431,11 +431,13 @@ public void Initialize(
/// the runspace. This method will be moved somewhere else soon.
///
///
- public Task ImportCommandsModuleAsync()
+ public Task ImportCommandsModuleAsync() => ImportCommandsModuleAsync(s_commandsModulePath);
+
+ public Task ImportCommandsModuleAsync(string path)
{
PSCommand importCommand = new PSCommand()
.AddCommand("Import-Module")
- .AddArgument(s_commandsModulePath);
+ .AddArgument(path);
return this.ExecuteCommandAsync(importCommand, sendOutputToHost: false, sendErrorToHost: false);
}
diff --git a/src/PowerShellEditorServices/Services/TextDocument/FoldingReference.cs b/src/PowerShellEditorServices/Services/TextDocument/FoldingReference.cs
index 477c27d88..d2e54be70 100644
--- a/src/PowerShellEditorServices/Services/TextDocument/FoldingReference.cs
+++ b/src/PowerShellEditorServices/Services/TextDocument/FoldingReference.cs
@@ -12,7 +12,7 @@ namespace Microsoft.PowerShell.EditorServices.Services.TextDocument
///
/// A class that holds the information for a foldable region of text in a document
///
- public class FoldingReference: IComparable
+ public class FoldingReference: IComparable, IEquatable
{
///
/// The zero-based line number from where the folded range starts.
@@ -59,8 +59,26 @@ public int CompareTo(FoldingReference that) {
if (this.EndCharacter > that.EndCharacter) { return 1; }
// They're the same range, but what about kind
- return that.Kind.Value - this.Kind.Value;
+ if (this.Kind == null)
+ {
+ if (that.Kind == null)
+ {
+ return 0;
+ }
+ // that has a kind but this doesn't.
+ return 1;
+ }
+
+ if (that.Kind != null)
+ {
+ return that.Kind.Value - this.Kind.Value;
+ }
+
+ // this has a kind but that doesn't.
+ return -1;
}
+
+ public bool Equals(FoldingReference other) => this.CompareTo(other) == 0;
}
///
diff --git a/test/PowerShellEditorServices.Test.Host/PowerShellEditorServices.Test.Host.csproj b/test/PowerShellEditorServices.Test.Host/PowerShellEditorServices.Test.Host.csproj
index c3a8876c1..055976699 100644
--- a/test/PowerShellEditorServices.Test.Host/PowerShellEditorServices.Test.Host.csproj
+++ b/test/PowerShellEditorServices.Test.Host/PowerShellEditorServices.Test.Host.csproj
@@ -11,7 +11,6 @@
-
diff --git a/test/PowerShellEditorServices.Test.Protocol/App.config b/test/PowerShellEditorServices.Test.Protocol/App.config
deleted file mode 100644
index 570b96dfb..000000000
--- a/test/PowerShellEditorServices.Test.Protocol/App.config
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test/PowerShellEditorServices.Test.Protocol/DebugAdapter/V8MessageSerializerTests.cs b/test/PowerShellEditorServices.Test.Protocol/DebugAdapter/V8MessageSerializerTests.cs
deleted file mode 100644
index 7dfd47c20..000000000
--- a/test/PowerShellEditorServices.Test.Protocol/DebugAdapter/V8MessageSerializerTests.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
-using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.Serializers;
-using Newtonsoft.Json.Linq;
-using Xunit;
-
-namespace Microsoft.PowerShell.EditorServices.Test.Protocol.DebugAdapter
-{
- public class TestMessageContents
- {
- public const string SomeFieldValue = "Some value";
- public const int NumberValue = 42;
-
- public string SomeField { get; set; }
-
- public int Number { get; set; }
-
- public TestMessageContents()
- {
- this.SomeField = SomeFieldValue;
- this.Number = NumberValue;
- }
- }
-
- public class V8MessageSerializerTests
- {
- private IMessageSerializer messageSerializer;
-
- private const string MessageId = "42";
- private const string MethodName = "testMethod";
- private static readonly JToken MessageContent = JToken.FromObject(new TestMessageContents());
-
- public V8MessageSerializerTests()
- {
- this.messageSerializer = new V8MessageSerializer();
- }
-
- [Fact]
- public void SerializesRequestMessages()
- {
- var messageObj =
- this.messageSerializer.SerializeMessage(
- Message.Request(
- MessageId,
- MethodName,
- MessageContent));
-
- AssertMessageFields(
- messageObj,
- checkSeq: true,
- checkCommand: true,
- checkParams: true);
- }
-
- [Fact]
- public void SerializesEventMessages()
- {
- var messageObj =
- this.messageSerializer.SerializeMessage(
- Message.Event(
- MethodName,
- MessageContent));
-
- AssertMessageFields(
- messageObj,
- checkEvent: true);
- }
-
- [Fact]
- public void SerializesResponseMessages()
- {
- var messageObj =
- this.messageSerializer.SerializeMessage(
- Message.Response(
- MessageId,
- MethodName,
- MessageContent));
-
- AssertMessageFields(
- messageObj,
- checkRequestSeq: true,
- checkCommand: true,
- checkResult: true);
- }
-
- [Fact]
- public void SerializesResponseWithErrorMessages()
- {
- var messageObj =
- this.messageSerializer.SerializeMessage(
- Message.ResponseError(
- MessageId,
- MethodName,
- MessageContent));
-
- AssertMessageFields(
- messageObj,
- checkRequestSeq: true,
- checkCommand: true,
- checkError: true);
- }
-
- private static void AssertMessageFields(
- JObject messageObj,
- bool checkSeq = false,
- bool checkRequestSeq = false,
- bool checkCommand = false,
- bool checkEvent = false,
- bool checkParams = false,
- bool checkResult = false,
- bool checkError = false)
- {
- JToken token = null;
-
- if (checkSeq)
- {
- Assert.True(messageObj.TryGetValue("seq", out token));
- Assert.Equal(MessageId, token.ToString());
- }
- else if (checkRequestSeq)
- {
- Assert.True(messageObj.TryGetValue("request_seq", out token));
- Assert.Equal(MessageId, token.ToString());
- }
-
- if (checkCommand)
- {
- Assert.True(messageObj.TryGetValue("command", out token));
- Assert.Equal(MethodName, token.ToString());
- }
- else if (checkEvent)
- {
- Assert.True(messageObj.TryGetValue("event", out token));
- Assert.Equal(MethodName, token.ToString());
- }
-
- if (checkError)
- {
- // TODO
- }
- else
- {
- string contentField = checkParams ? "arguments" : "body";
- Assert.True(messageObj.TryGetValue(contentField, out token));
- Assert.True(JToken.DeepEquals(token, MessageContent));
- }
- }
- }
-}
-
diff --git a/test/PowerShellEditorServices.Test.Protocol/LanguageServer/JsonRpcMessageSerializerTests.cs b/test/PowerShellEditorServices.Test.Protocol/LanguageServer/JsonRpcMessageSerializerTests.cs
deleted file mode 100644
index 876ca87a3..000000000
--- a/test/PowerShellEditorServices.Test.Protocol/LanguageServer/JsonRpcMessageSerializerTests.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
-using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.Serializers;
-using Newtonsoft.Json.Linq;
-using Xunit;
-
-namespace Microsoft.PowerShell.EditorServices.Test.Protocol.LanguageServer
-{
- public class TestMessageContents
- {
- public const string SomeFieldValue = "Some value";
- public const int NumberValue = 42;
-
- public string SomeField { get; set; }
-
- public int Number { get; set; }
-
- public TestMessageContents()
- {
- this.SomeField = SomeFieldValue;
- this.Number = NumberValue;
- }
- }
-
- public class JsonRpcMessageSerializerTests
- {
- private IMessageSerializer messageSerializer;
-
- private const string MessageId = "42";
- private const string MethodName = "testMethod";
- private static readonly JToken MessageContent = JToken.FromObject(new TestMessageContents());
-
- public JsonRpcMessageSerializerTests()
- {
- this.messageSerializer = new JsonRpcMessageSerializer();
- }
-
- [Fact]
- public void SerializesRequestMessages()
- {
- var messageObj =
- this.messageSerializer.SerializeMessage(
- Message.Request(
- MessageId,
- MethodName,
- MessageContent));
-
- AssertMessageFields(
- messageObj,
- checkId: true,
- checkMethod: true,
- checkParams: true);
- }
-
- [Fact]
- public void SerializesEventMessages()
- {
- var messageObj =
- this.messageSerializer.SerializeMessage(
- Message.Event(
- MethodName,
- MessageContent));
-
- AssertMessageFields(
- messageObj,
- checkMethod: true,
- checkParams: true);
- }
-
- [Fact]
- public void SerializesResponseMessages()
- {
- var messageObj =
- this.messageSerializer.SerializeMessage(
- Message.Response(
- MessageId,
- null,
- MessageContent));
-
- AssertMessageFields(
- messageObj,
- checkId: true,
- checkResult: true);
- }
-
- [Fact]
- public void SerializesResponseWithErrorMessages()
- {
- var messageObj =
- this.messageSerializer.SerializeMessage(
- Message.ResponseError(
- MessageId,
- null,
- MessageContent));
-
- AssertMessageFields(
- messageObj,
- checkId: true,
- checkError: true);
- }
-
- private static void AssertMessageFields(
- JObject messageObj,
- bool checkId = false,
- bool checkMethod = false,
- bool checkParams = false,
- bool checkResult = false,
- bool checkError = false)
- {
- JToken token = null;
-
- Assert.True(messageObj.TryGetValue("jsonrpc", out token));
- Assert.Equal("2.0", token.ToString());
-
- if (checkId)
- {
- Assert.True(messageObj.TryGetValue("id", out token));
- Assert.Equal(MessageId, token.ToString());
- }
-
- if (checkMethod)
- {
- Assert.True(messageObj.TryGetValue("method", out token));
- Assert.Equal(MethodName, token.ToString());
- }
-
- if (checkError)
- {
- // TODO
- }
- else
- {
- string contentField = checkParams ? "params" : "result";
- Assert.True(messageObj.TryGetValue(contentField, out token));
- Assert.True(JToken.DeepEquals(token, MessageContent));
- }
- }
- }
-}
-
diff --git a/test/PowerShellEditorServices.Test.Protocol/Message/MessageReaderWriterTests.cs b/test/PowerShellEditorServices.Test.Protocol/Message/MessageReaderWriterTests.cs
deleted file mode 100644
index 9d637007d..000000000
--- a/test/PowerShellEditorServices.Test.Protocol/Message/MessageReaderWriterTests.cs
+++ /dev/null
@@ -1,184 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
-using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.Serializers;
-using System;
-using System.IO;
-using System.Text;
-using System.Threading.Tasks;
-using Xunit;
-using Microsoft.PowerShell.EditorServices.Utility;
-
-namespace Microsoft.PowerShell.EditorServices.Test.Protocol.MessageProtocol
-{
- public class MessageReaderWriterTests
- {
- const string TestEventString = "{\"type\":\"event\",\"event\":\"testEvent\",\"body\":null}";
- const string TestEventFormatString = "{{\"event\":\"testEvent\",\"body\":{{\"someString\":\"{0}\"}},\"seq\":0,\"type\":\"event\"}}";
- readonly int ExpectedMessageByteCount = Encoding.UTF8.GetByteCount(TestEventString);
-
- private ILogger logger;
- private IMessageSerializer messageSerializer;
-
- public MessageReaderWriterTests()
- {
- this.logger = Logging.NullLogger;
- this.messageSerializer = new V8MessageSerializer();
- }
-
- [Fact]
- public async Task WritesMessage()
- {
- MemoryStream outputStream = new MemoryStream();
-
- MessageWriter messageWriter =
- new MessageWriter(
- outputStream,
- this.messageSerializer,
- this.logger);
-
- // Write the message and then roll back the stream to be read
- // TODO: This will need to be redone!
- await messageWriter.WriteMessageAsync(Message.Event("testEvent", null));
- outputStream.Seek(0, SeekOrigin.Begin);
-
- string expectedHeaderString =
- string.Format(
- Constants.ContentLengthFormatString,
- ExpectedMessageByteCount);
-
- byte[] buffer = new byte[128];
- await outputStream.ReadAsync(buffer, 0, expectedHeaderString.Length);
-
- Assert.Equal(
- expectedHeaderString,
- Encoding.ASCII.GetString(buffer, 0, expectedHeaderString.Length));
-
- // Read the message
- await outputStream.ReadAsync(buffer, 0, ExpectedMessageByteCount);
-
- Assert.Equal(
- TestEventString,
- Encoding.UTF8.GetString(buffer, 0, ExpectedMessageByteCount));
-
- outputStream.Dispose();
- }
-
- [Fact]
- public void ReadsMessage()
- {
- MemoryStream inputStream = new MemoryStream();
- MessageReader messageReader =
- new MessageReader(
- inputStream,
- this.messageSerializer,
- this.logger);
-
- // Write a message to the stream
- byte[] messageBuffer = this.GetMessageBytes(TestEventString);
- inputStream.Write(
- this.GetMessageBytes(TestEventString),
- 0,
- messageBuffer.Length);
-
- inputStream.Flush();
- inputStream.Seek(0, SeekOrigin.Begin);
-
- Message messageResult = messageReader.ReadMessageAsync().Result;
- Assert.Equal("testEvent", messageResult.Method);
-
- inputStream.Dispose();
- }
-
- [Fact]
- public void ReadsManyBufferedMessages()
- {
- MemoryStream inputStream = new MemoryStream();
- MessageReader messageReader =
- new MessageReader(
- inputStream,
- this.messageSerializer,
- this.logger);
-
- // Get a message to use for writing to the stream
- byte[] messageBuffer = this.GetMessageBytes(TestEventString);
-
- // How many messages of this size should we write to overflow the buffer?
- int overflowMessageCount =
- (int)Math.Ceiling(
- (MessageReader.DefaultBufferSize * 1.5) / messageBuffer.Length);
-
- // Write the necessary number of messages to the stream
- for (int i = 0; i < overflowMessageCount; i++)
- {
- inputStream.Write(messageBuffer, 0, messageBuffer.Length);
- }
-
- inputStream.Flush();
- inputStream.Seek(0, SeekOrigin.Begin);
-
- // Read the written messages from the stream
- for (int i = 0; i < overflowMessageCount; i++)
- {
- Message messageResult = messageReader.ReadMessageAsync().Result;
- Assert.Equal("testEvent", messageResult.Method);
- }
-
- inputStream.Dispose();
- }
-
- [Fact]
- public void ReaderResizesBufferForLargeMessages()
- {
- MemoryStream inputStream = new MemoryStream();
- MessageReader messageReader =
- new MessageReader(
- inputStream,
- this.messageSerializer,
- this.logger);
-
- // Get a message with content so large that the buffer will need
- // to be resized to fit it all.
- byte[] messageBuffer =
- this.GetMessageBytes(
- string.Format(
- TestEventFormatString,
- new String('X', (int)(MessageReader.DefaultBufferSize * 3))));
-
- inputStream.Write(messageBuffer, 0, messageBuffer.Length);
- inputStream.Flush();
- inputStream.Seek(0, SeekOrigin.Begin);
-
- Message messageResult = messageReader.ReadMessageAsync().Result;
- Assert.Equal("testEvent", messageResult.Method);
-
- inputStream.Dispose();
- }
-
- private byte[] GetMessageBytes(string messageString, Encoding encoding = null)
- {
- if (encoding == null)
- {
- encoding = Encoding.UTF8;
- }
-
- byte[] messageBytes = Encoding.UTF8.GetBytes(messageString);
- byte[] headerBytes =
- Encoding.ASCII.GetBytes(
- string.Format(
- Constants.ContentLengthFormatString,
- messageBytes.Length));
-
- // Copy the bytes into a single buffer
- byte[] finalBytes = new byte[headerBytes.Length + messageBytes.Length];
- Buffer.BlockCopy(headerBytes, 0, finalBytes, 0, headerBytes.Length);
- Buffer.BlockCopy(messageBytes, 0, finalBytes, headerBytes.Length, messageBytes.Length);
-
- return finalBytes;
- }
- }
-}
-
diff --git a/test/PowerShellEditorServices.Test.Protocol/Message/TestMessageTypes.cs b/test/PowerShellEditorServices.Test.Protocol/Message/TestMessageTypes.cs
deleted file mode 100644
index 4b65c78e8..000000000
--- a/test/PowerShellEditorServices.Test.Protocol/Message/TestMessageTypes.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
-using System;
-using System.Threading.Tasks;
-
-namespace Microsoft.PowerShell.EditorServices.Test.Protocol.MessageProtocol
-{
- #region Request Types
-
- internal class TestRequest
- {
- public Task ProcessMessage(
- EditorSession editorSession,
- MessageWriter messageWriter)
- {
- return Task.FromResult(false);
- }
- }
-
- internal class TestRequestArguments
- {
- public string SomeString { get; set; }
- }
-
- #endregion
-
- #region Response Types
-
- internal class TestResponse
- {
- }
-
- internal class TestResponseBody
- {
- public string SomeString { get; set; }
- }
-
- #endregion
-
- #region Event Types
-
- internal class TestEvent
- {
- }
-
- internal class TestEventBody
- {
- public string SomeString { get; set; }
- }
-
- #endregion
-}
diff --git a/test/PowerShellEditorServices.Test.Protocol/PowerShellEditorServices.Test.Protocol.csproj b/test/PowerShellEditorServices.Test.Protocol/PowerShellEditorServices.Test.Protocol.csproj
deleted file mode 100644
index 0059f2639..000000000
--- a/test/PowerShellEditorServices.Test.Protocol/PowerShellEditorServices.Test.Protocol.csproj
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- netcoreapp2.1;net461
- Microsoft.PowerShell.EditorServices.Test.Protocol
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(DefineConstants);CoreCLR
-
-
-
-
-
diff --git a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs b/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs
deleted file mode 100644
index 100ea9076..000000000
--- a/test/PowerShellEditorServices.Test.Protocol/Server/OutputDebouncerTests.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-using Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter;
-using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
-using Microsoft.PowerShell.EditorServices.Protocol.Server;
-using Microsoft.PowerShell.EditorServices.Test.Shared;
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Xunit;
-
-namespace Microsoft.PowerShell.EditorServices.Test.Protocol.Server
-{
- public class OutputDebouncerTests
- {
- [Fact]
- public async Task OutputDebouncerAggregatesOutputEvents()
- {
- TestMessageSender messageSender = new TestMessageSender();
- OutputDebouncer debouncer = new OutputDebouncer(messageSender);
-
- await SendOutput(debouncer, "This ");
- await SendOutput(debouncer, "is a ");
- await SendOutput(debouncer, "test", true);
- await SendOutput(debouncer, "Another line");
-
- // Make sure no output events have been written yet
- Assert.Empty(messageSender.OutputEvents);
-
- // Wait for the output to be flushed
- await Task.Delay(OutputDebouncer.OutputFlushInterval + 100);
-
- // Write some more output after the first flush
- await SendOutput(debouncer, "Another test line", true);
- await SendOutput(debouncer, "for great justice");
-
- // Assert that there's only one event with the expected string
- Assert.Single(messageSender.OutputEvents);
- Assert.Equal(
- TestUtilities.NormalizeNewlines("This is a test\nAnother line"),
- messageSender.OutputEvents[0].Output);
-
- // Wait for the next output to be flushed
- await Task.Delay(OutputDebouncer.OutputFlushInterval + 100);
-
- // Assert that there's only one event with the expected string
- Assert.Equal(2, messageSender.OutputEvents.Count);
- Assert.Equal(
- TestUtilities.NormalizeNewlines("Another test line\nfor great justice"),
- messageSender.OutputEvents[1].Output);
- }
-
- [Fact]
- public async Task OutputDebouncerDoesNotDuplicateOutput()
- {
- TestMessageSender messageSender = new TestMessageSender();
- OutputDebouncer debouncer = new OutputDebouncer(messageSender);
-
- // Send many messages in quick succession to ensure that
- // output is not being duplicated in subsequent events.
- for (int i = 1; i <= 50; i++)
- {
- await SendOutput(debouncer, "Output " + i, true);
-
- if (i == 25)
- {
- // Artificially insert a delay to force another event
- await Task.Delay(OutputDebouncer.OutputFlushInterval + 100);
- }
- }
-
- // Wait for the final event to be written
- await Task.Delay(OutputDebouncer.OutputFlushInterval + 100);
-
- // Ensure that the two events start with the correct lines
- Assert.Equal(2, messageSender.OutputEvents.Count);
- Assert.Equal("Output 1", messageSender.OutputEvents[0].Output.Split('\n')[0].Trim('\r'));
- Assert.Equal("Output 26", messageSender.OutputEvents[1].Output.Split('\n')[0].Trim('\r'));
- }
-
- private static Task SendOutput(
- OutputDebouncer debouncer,
- string outputText,
- bool includeNewLine = false)
- {
- return debouncer.InvokeAsync(
- new OutputWrittenEventArgs(
- outputText,
- includeNewLine,
- OutputType.Normal,
- ConsoleColor.White,
- ConsoleColor.Black));
- }
- }
-
- internal class TestMessageSender : IMessageSender
- {
- public List OutputEvents { get; } = new List();
-
- public Task SendEventAsync(
- NotificationType eventType,
- TParams eventParams)
- {
- OutputEventBody outputEvent = eventParams as OutputEventBody;
-
- if (outputEvent != null)
- {
- this.OutputEvents.Add(outputEvent);
- }
-
- return Task.FromResult(true);
- }
-
- public Task SendRequestAsync(
- RequestType requestType,
- TParams requestParams, bool waitForResponse)
- {
- // Legitimately not implemented for these tests.
- throw new NotImplementedException();
- }
-
- public Task SendRequestAsync(RequestType0 requestType0)
- {
- // Legitimately not implemented for these tests.
- throw new NotImplementedException();
- }
- }
-}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteAttributeValue.cs b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteAttributeValue.cs
index 43bf5bc86..ceba353fd 100644
--- a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteAttributeValue.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteAttributeValue.cs
@@ -3,17 +3,22 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
{
public class CompleteAttributeValue
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
- StartLineNumber = 16,
- StartColumnNumber = 38
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
+ text: string.Empty,
+ startLineNumber: 16,
+ startColumnNumber: 38,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
public static readonly BufferRange ExpectedRange =
new BufferRange(
diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandFromModule.cs b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandFromModule.cs
index 5b03f9183..bc5b2ff9d 100644
--- a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandFromModule.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandFromModule.cs
@@ -4,7 +4,7 @@
//
using System;
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
{
@@ -16,12 +16,15 @@ public class CompleteCommandFromModule
};
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
- StartLineNumber = 13,
- StartColumnNumber = 8
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
+ text: string.Empty,
+ startLineNumber: 13,
+ startColumnNumber: 8,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
public static readonly CompletionDetails ExpectedCompletion =
CompletionDetails.Create(
diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandInFile.cs b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandInFile.cs
index 93bfb739d..a4d4b7576 100644
--- a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandInFile.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandInFile.cs
@@ -3,19 +3,22 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
{
public class CompleteCommandInFile
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
- StartLineNumber = 8,
- StartColumnNumber = 7
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
+ text: string.Empty,
+ startLineNumber: 8,
+ startColumnNumber: 7,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
public static readonly CompletionDetails ExpectedCompletion =
CompletionDetails.Create(
@@ -24,4 +27,3 @@ public class CompleteCommandInFile
"Get-Something");
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteFilePath.cs b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteFilePath.cs
index 1d2a77863..828b17061 100644
--- a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteFilePath.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteFilePath.cs
@@ -3,23 +3,22 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
{
public class CompleteFilePath
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
- StartLineNumber = 19,
- StartColumnNumber = 15
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
+ text: string.Empty,
+ startLineNumber: 19,
+ startColumnNumber: 15,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
public static readonly BufferRange ExpectedRange =
new BufferRange(
diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteVariableInFile.cs b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteVariableInFile.cs
index 3a7bd4b40..92e38e8d8 100644
--- a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteVariableInFile.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteVariableInFile.cs
@@ -3,19 +3,22 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
{
public class CompleteVariableInFile
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
- StartLineNumber = 10,
- StartColumnNumber = 9
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
+ text: string.Empty,
+ startLineNumber: 10,
+ startColumnNumber: 9,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
public static readonly CompletionDetails ExpectedCompletion =
CompletionDetails.Create(
@@ -24,4 +27,3 @@ public class CompleteVariableInFile
"testVar1");
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/Definition/FindsDotSourcedFile.cs b/test/PowerShellEditorServices.Test.Shared/Definition/FindsDotSourcedFile.cs
index 8147334c8..d4b262bbc 100644
--- a/test/PowerShellEditorServices.Test.Shared/Definition/FindsDotSourcedFile.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Definition/FindsDotSourcedFile.cs
@@ -3,18 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
{
public class FindsDotSourcedFile
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizeNewlines("References/DotSources.ps1"),
- StartLineNumber = 1,
- StartColumnNumber = 3
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/DotSources.ps1"),
+ text: string.Empty,
+ startLineNumber: 1,
+ startColumnNumber: 3,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
diff --git a/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinition.cs b/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinition.cs
index 387e8e58b..8f3cea442 100644
--- a/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinition.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinition.cs
@@ -3,16 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
{
public class FindsFunctionDefinition
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/SimpleFile.ps1"),
- StartLineNumber = 3,
- StartColumnNumber = 12
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
+ text: string.Empty,
+ startLineNumber: 3,
+ startColumnNumber: 12,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
diff --git a/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinitionInDotSourceReference.cs b/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinitionInDotSourceReference.cs
index e8fb1f3b5..f1a9f7ed6 100644
--- a/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinitionInDotSourceReference.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinitionInDotSourceReference.cs
@@ -3,18 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
{
public class FindsFunctionDefinitionInDotSourceReference
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/FileWithReferences.ps1"),
- StartLineNumber = 3,
- StartColumnNumber = 6
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/FileWithReferences.ps1"),
+ text: string.Empty,
+ startLineNumber: 3,
+ startColumnNumber: 6,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
diff --git a/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinitionInWorkspace.cs b/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinitionInWorkspace.cs
index 1c48cfefe..af54287a2 100644
--- a/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinitionInWorkspace.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Definition/FindsFunctionDefinitionInWorkspace.cs
@@ -3,18 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
{
public class FindsFunctionDefinitionInWorkspace
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/ReferenceFileD.ps1"),
- StartLineNumber = 1,
- StartColumnNumber = 2
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/ReferenceFileD.ps1"),
+ text: string.Empty,
+ startLineNumber: 1,
+ startColumnNumber: 2,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
diff --git a/test/PowerShellEditorServices.Test.Shared/Definition/FindsVariableDefinition.cs b/test/PowerShellEditorServices.Test.Shared/Definition/FindsVariableDefinition.cs
index 1c785be21..b128cb5f9 100644
--- a/test/PowerShellEditorServices.Test.Shared/Definition/FindsVariableDefinition.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Definition/FindsVariableDefinition.cs
@@ -3,23 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Definition
{
public class FindsVariableDefinition
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/SimpleFile.ps1"),
- StartLineNumber = 8,
- StartColumnNumber = 3
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
+ text: string.Empty,
+ startLineNumber: 8,
+ startColumnNumber: 3,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/Occurrences/FindOccurrencesOnParameter.cs b/test/PowerShellEditorServices.Test.Shared/Occurrences/FindOccurrencesOnParameter.cs
index 7b3c368b7..3d79b2922 100644
--- a/test/PowerShellEditorServices.Test.Shared/Occurrences/FindOccurrencesOnParameter.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Occurrences/FindOccurrencesOnParameter.cs
@@ -3,17 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Occurrences
{
public class FindOccurrencesOnParameter
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/SimpleFile.ps1"),
- StartLineNumber = 1,
- StartColumnNumber = 31
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
+ text: string.Empty,
+ startLineNumber: 1,
+ startColumnNumber: 31,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/Occurrences/FindsOccurrencesOnFunction.cs b/test/PowerShellEditorServices.Test.Shared/Occurrences/FindsOccurrencesOnFunction.cs
index 72c2adf95..7871d68af 100644
--- a/test/PowerShellEditorServices.Test.Shared/Occurrences/FindsOccurrencesOnFunction.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Occurrences/FindsOccurrencesOnFunction.cs
@@ -3,19 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Occurrences
{
public class FindsOccurrencesOnFunction
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/SimpleFile.ps1"),
- StartLineNumber = 1,
- StartColumnNumber = 17
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
+ text: string.Empty,
+ startLineNumber: 1,
+ startColumnNumber: 17,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/ParameterHints/FindsParameterSetsOnCommand.cs b/test/PowerShellEditorServices.Test.Shared/ParameterHints/FindsParameterSetsOnCommand.cs
index 797d93bd1..db4dc0af5 100644
--- a/test/PowerShellEditorServices.Test.Shared/ParameterHints/FindsParameterSetsOnCommand.cs
+++ b/test/PowerShellEditorServices.Test.Shared/ParameterHints/FindsParameterSetsOnCommand.cs
@@ -3,18 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.ParameterHint
{
public class FindsParameterSetsOnCommand
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("ParameterHints/ParamHints.ps1"),
- StartLineNumber = 1,
- StartColumnNumber = 14
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("ParameterHints/ParamHints.ps1"),
+ text: string.Empty,
+ startLineNumber: 1,
+ startColumnNumber: 14,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
diff --git a/test/PowerShellEditorServices.Test.Shared/ParameterHints/FindsParameterSetsOnCommandWithSpaces.cs b/test/PowerShellEditorServices.Test.Shared/ParameterHints/FindsParameterSetsOnCommandWithSpaces.cs
index e7d40489e..ce3bb3194 100644
--- a/test/PowerShellEditorServices.Test.Shared/ParameterHints/FindsParameterSetsOnCommandWithSpaces.cs
+++ b/test/PowerShellEditorServices.Test.Shared/ParameterHints/FindsParameterSetsOnCommandWithSpaces.cs
@@ -3,17 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.ParameterHint
{
public class FindsParameterSetsOnCommandWithSpaces
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("ParameterHints/ParamHints.ps1"),
- StartLineNumber = 9,
- StartColumnNumber = 31
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("ParameterHints/ParamHints.ps1"),
+ text: string.Empty,
+ startLineNumber: 9,
+ startColumnNumber: 31,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnBuiltInCommandWithAlias.cs b/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnBuiltInCommandWithAlias.cs
index c06e2452c..f3b9c1e55 100644
--- a/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnBuiltInCommandWithAlias.cs
+++ b/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnBuiltInCommandWithAlias.cs
@@ -3,27 +3,35 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.References
{
public class FindsReferencesOnBuiltInCommandWithAlias
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/SimpleFile.ps1"),
- StartLineNumber = 14,
- StartColumnNumber = 3
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
+ text: string.Empty,
+ startLineNumber: 14,
+ startColumnNumber: 3,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
public class FindsReferencesOnBuiltInAlias
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/SimpleFile.ps1"),
- StartLineNumber = 15,
- StartColumnNumber = 2
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
+ text: string.Empty,
+ startLineNumber: 15,
+ startColumnNumber: 2,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
diff --git a/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnFunction.cs b/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnFunction.cs
index 28c3249fd..51a7ad6f2 100644
--- a/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnFunction.cs
+++ b/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnFunction.cs
@@ -3,17 +3,22 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.References
{
public class FindsReferencesOnFunction
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/SimpleFile.ps1"),
- StartLineNumber = 3,
- StartColumnNumber = 8
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
+ text: string.Empty,
+ startLineNumber: 3,
+ startColumnNumber: 8,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
diff --git a/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnFunctionMultiFileDotSource.cs b/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnFunctionMultiFileDotSource.cs
index 872df6ff1..b165162ac 100644
--- a/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnFunctionMultiFileDotSource.cs
+++ b/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesOnFunctionMultiFileDotSource.cs
@@ -3,29 +3,35 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.References
{
public class FindsReferencesOnFunctionMultiFileDotSourceFileB
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/ReferenceFileB.ps1"),
- StartLineNumber = 5,
- StartColumnNumber = 8
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/ReferenceFileB.ps1"),
+ text: string.Empty,
+ startLineNumber: 5,
+ startColumnNumber: 8,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
public class FindsReferencesOnFunctionMultiFileDotSourceFileC
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/ReferenceFileC.ps1"),
- StartLineNumber = 4,
- StartColumnNumber = 10
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/ReferenceFileC.ps1"),
+ text: string.Empty,
+ startLineNumber: 4,
+ startColumnNumber: 10,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
diff --git a/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesonVariable.cs b/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesonVariable.cs
index 1860e56d9..ffd6396cf 100644
--- a/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesonVariable.cs
+++ b/test/PowerShellEditorServices.Test.Shared/References/FindsReferencesonVariable.cs
@@ -3,19 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
namespace Microsoft.PowerShell.EditorServices.Test.Shared.References
{
public class FindsReferencesOnVariable
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("References/SimpleFile.ps1"),
- StartLineNumber = 10,
- StartColumnNumber = 17
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("References/SimpleFile.ps1"),
+ text: string.Empty,
+ startLineNumber: 10,
+ startColumnNumber: 17,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/SymbolDetails/FindsDetailsForBuiltInCommand.cs b/test/PowerShellEditorServices.Test.Shared/SymbolDetails/FindsDetailsForBuiltInCommand.cs
index d46206bcb..751a66236 100644
--- a/test/PowerShellEditorServices.Test.Shared/SymbolDetails/FindsDetailsForBuiltInCommand.cs
+++ b/test/PowerShellEditorServices.Test.Shared/SymbolDetails/FindsDetailsForBuiltInCommand.cs
@@ -3,16 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.SymbolDetails
{
public class FindsDetailsForBuiltInCommand
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("SymbolDetails/SymbolDetails.ps1"),
- StartLineNumber = 1,
- StartColumnNumber = 10
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("SymbolDetails/SymbolDetails.ps1"),
+ text: string.Empty,
+ startLineNumber: 1,
+ startColumnNumber: 10,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
diff --git a/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInMultiSymbolFile.cs b/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInMultiSymbolFile.cs
index ab3ce87b3..91b03b3bd 100644
--- a/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInMultiSymbolFile.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInMultiSymbolFile.cs
@@ -3,14 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
{
public class FindSymbolsInMultiSymbolFile
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion {
- File = TestUtilities.NormalizePath("Symbols/MultipleSymbols.ps1")
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Symbols/MultipleSymbols.ps1"),
+ text: string.Empty,
+ startLineNumber: 0,
+ startColumnNumber: 0,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInNoSymbolsFile.cs b/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInNoSymbolsFile.cs
index c8c814ca0..6cfac5385 100644
--- a/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInNoSymbolsFile.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInNoSymbolsFile.cs
@@ -3,14 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
{
public class FindSymbolsInNoSymbolsFile
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion {
- File = TestUtilities.NormalizePath("Symbols/NoSymbols.ps1")
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Symbols/NoSymbols.ps1"),
+ text: string.Empty,
+ startLineNumber: 0,
+ startColumnNumber: 0,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInPSDFile.cs b/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInPSDFile.cs
index 6343b79cc..304539ad3 100644
--- a/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInPSDFile.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInPSDFile.cs
@@ -3,15 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
{
public class FindSymbolsInPSDFile
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("Symbols/PowerShellDataFile.psd1")
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Symbols/PowerShellDataFile.psd1"),
+ text: string.Empty,
+ startLineNumber: 0,
+ startColumnNumber: 0,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
-
diff --git a/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInPesterFile.cs b/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInPesterFile.cs
index 19a7c6519..2a8fda4cc 100644
--- a/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInPesterFile.cs
+++ b/test/PowerShellEditorServices.Test.Shared/Symbols/FindSymbolsInPesterFile.cs
@@ -3,15 +3,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
namespace Microsoft.PowerShell.EditorServices.Test.Shared.Symbols
{
public class FindSymbolsInPesterFile
{
public static readonly ScriptRegion SourceDetails =
- new ScriptRegion
- {
- File = TestUtilities.NormalizePath("Symbols/PesterFile.tests.ps1")
- };
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Symbols/PesterFile.tests.ps1"),
+ text: string.Empty,
+ startLineNumber: 0,
+ startColumnNumber: 0,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
}
}
-
diff --git a/test/PowerShellEditorServices.Test/Console/ChoicePromptHandlerTests.cs b/test/PowerShellEditorServices.Test/Console/ChoicePromptHandlerTests.cs
index 55f8b60e9..3dc6b47cc 100644
--- a/test/PowerShellEditorServices.Test/Console/ChoicePromptHandlerTests.cs
+++ b/test/PowerShellEditorServices.Test/Console/ChoicePromptHandlerTests.cs
@@ -3,11 +3,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices.Console;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Extensions.Logging.Abstractions;
+using Microsoft.PowerShell.EditorServices.Services.PowerShellContext;
using Xunit;
-using Microsoft.PowerShell.EditorServices.Utility;
namespace Microsoft.PowerShell.EditorServices.Test.Console
{
@@ -23,6 +23,7 @@ public class ChoicePromptHandlerTests
private const int DefaultChoice = 1;
+ [Trait("Category", "Prompt")]
[Fact]
public void ChoicePromptReturnsCorrectIdForChoice()
{
@@ -45,6 +46,7 @@ public void ChoicePromptReturnsCorrectIdForChoice()
Assert.Equal(1, choicePromptHandler.TimesPrompted);
}
+ [Trait("Category", "Prompt")]
[Fact]
public void ChoicePromptReturnsCorrectIdForHotKey()
{
@@ -68,8 +70,9 @@ public void ChoicePromptReturnsCorrectIdForHotKey()
Assert.Equal(1, choicePromptHandler.TimesPrompted);
}
+ [Trait("Category", "Prompt")]
[Fact]
- public void ChoicePromptRepromptsOnInvalidInput()
+ public async Task ChoicePromptRepromptsOnInvalidInput()
{
TestChoicePromptHandler choicePromptHandler =
new TestChoicePromptHandler();
@@ -85,6 +88,9 @@ public void ChoicePromptRepromptsOnInvalidInput()
// Choice is invalid, should reprompt
choicePromptHandler.ReturnInputString("INVALID");
+ // Give time for the prompt to reappear.
+ await Task.Delay(1000).ConfigureAwait(false);
+
Assert.Equal(TaskStatus.WaitingForActivation, promptTask.Status);
Assert.Equal(2, choicePromptHandler.TimesPrompted);
}
@@ -96,7 +102,7 @@ internal class TestChoicePromptHandler : ChoicePromptHandler
public int TimesPrompted { get; private set; }
- public TestChoicePromptHandler() : base(Logging.NullLogger)
+ public TestChoicePromptHandler() : base(NullLogger.Instance)
{
}
diff --git a/test/PowerShellEditorServices.Test/Console/ConsoleServiceTests.cs b/test/PowerShellEditorServices.Test/Console/ConsoleServiceTests.cs
deleted file mode 100644
index 14dda1fa0..000000000
--- a/test/PowerShellEditorServices.Test/Console/ConsoleServiceTests.cs
+++ /dev/null
@@ -1,674 +0,0 @@
-// //
-// // Copyright (c) Microsoft. All rights reserved.
-// // Licensed under the MIT license. See LICENSE file in the project root for full license information.
-// //
-
-// using Microsoft.PowerShell.EditorServices.Console;
-// using Microsoft.PowerShell.EditorServices.Utility;
-// using System;
-// using System.Collections.Generic;
-// using System.Linq;
-// using System.Security;
-// using System.Text;
-// using System.Threading;
-// using System.Threading.Tasks;
-// using Xunit;
-
-// namespace Microsoft.PowerShell.EditorServices.Test.Console
-// {
-// public class ConsoleServiceTests : IDisposable
-// {
-// private ConsoleService consoleService;
-// private PowerShellContext powerShellContext;
-// private TestConsolePromptHandlerContext promptHandlerContext;
-
-// private Dictionary outputPerType =
-// new Dictionary();
-
-// const string TestOutputString = "This is a test.";
-
-// const string PromptCaption = "Test Prompt";
-// const string PromptMessage = "Make a selection";
-// const int PromptDefault = 1;
-
-// static readonly Tuple[] PromptChoices =
-// new Tuple[]
-// {
-// new Tuple("&Apple", "Help for Apple"),
-// new Tuple("Ba&nana", "Help for Banana"),
-// new Tuple("Orange", "Help for Orange")
-// };
-
-// static readonly Tuple[] PromptFields =
-// new Tuple[]
-// {
-// new Tuple("Name", typeof(string)),
-// new Tuple("Age", typeof(int)),
-// new Tuple("Books", typeof(string[])),
-// };
-
-// public ConsoleServiceTests()
-// {
-// this.powerShellContext = new PowerShellContext();
-// EditorServicesPSHost psHost =
-// new EditorServicesPSHost(
-// powerShellContext,
-// PowerShellContextTests.TestHostDetails,
-// false);
-
-// this.consoleService = psHost.ConsoleService;
-
-// this.powerShellContext.Initialize(
-// null,
-// PowerShellContext.CreateRunspace(psHost),
-// true);
-
-// this.promptHandlerContext =
-// new TestConsolePromptHandlerContext();
-
-// this.consoleService.PushPromptHandlerContext(this.promptHandlerContext);
-// this.consoleService.OutputWritten += OnOutputWritten;
-// promptHandlerContext.ConsoleHost = this.consoleService;
-// }
-
-// public void Dispose()
-// {
-// this.powerShellContext.Dispose();
-// }
-
-// [Fact]
-// public async Task ReceivesNormalOutput()
-// {
-// await this.powerShellContext.ExecuteScriptString(
-// string.Format(
-// "\"{0}\"",
-// TestOutputString));
-
-// // Prompt strings are returned as normal output, ignore the prompt
-// string[] normalOutputLines =
-// this.GetOutputForType(OutputType.Normal)
-// .Split(
-// new string[] { Environment.NewLine },
-// StringSplitOptions.None);
-
-// // The output should be 2 lines: the expected string and
-// // an empty line.
-// Assert.Equal(2, normalOutputLines.Length);
-// Assert.Equal(
-// TestOutputString,
-// normalOutputLines[0]);
-// }
-
-// [Fact]
-// public async Task ReceivesErrorOutput()
-// {
-// await this.powerShellContext.ExecuteScriptString(
-// string.Format(
-// "Write-Error \"{0}\"",
-// TestOutputString));
-
-// string errorString = this.GetOutputForType(OutputType.Error).Split('\r')[0];
-
-// Assert.Equal(
-// string.Format("Write-Error \"{0}\" : {0}", TestOutputString),
-// errorString);
-// }
-
-// [Fact]
-// public async Task ReceivesVerboseOutput()
-// {
-// // Since setting VerbosePreference causes other message to
-// // be written out when we run our test, run a command preemptively
-// // to flush out unwanted verbose messages
-// await this.powerShellContext.ExecuteScriptString("Write-Verbose \"Preloading\"");
-
-// await this.powerShellContext.ExecuteScriptString(
-// string.Format(
-// "$VerbosePreference = \"Continue\"; Write-Verbose \"{0}\"",
-// TestOutputString));
-
-// Assert.Equal(
-// EditorServicesPSHostUserInterface.VerboseMessagePrefix + TestOutputString + Environment.NewLine,
-// this.GetOutputForType(OutputType.Verbose));
-// }
-
-// [Fact]
-// public async Task ReceivesDebugOutput()
-// {
-// // Since setting VerbosePreference causes other message to
-// // be written out when we run our test, run a command preemptively
-// // to flush out unwanted verbose messages
-// await this.powerShellContext.ExecuteScriptString("Write-Verbose \"Preloading\"");
-
-// await this.powerShellContext.ExecuteScriptString(
-// string.Format(
-// "$DebugPreference = \"Continue\"; Write-Debug \"{0}\"",
-// TestOutputString));
-
-// Assert.Equal(
-// EditorServicesPSHostUserInterface.DebugMessagePrefix + TestOutputString + Environment.NewLine,
-// this.GetOutputForType(OutputType.Debug));
-// }
-
-// [Fact]
-// public async Task ReceivesWarningOutput()
-// {
-// await this.powerShellContext.ExecuteScriptString(
-// string.Format(
-// "Write-Warning \"{0}\"",
-// TestOutputString));
-
-// Assert.Equal(
-// EditorServicesPSHostUserInterface.WarningMessagePrefix + TestOutputString + Environment.NewLine,
-// this.GetOutputForType(OutputType.Warning));
-// }
-
-// [Fact]
-// public async Task ReceivesChoicePrompt()
-// {
-// string choiceScript =
-// this.GetChoicePromptString(
-// PromptCaption,
-// PromptMessage,
-// PromptChoices,
-// PromptDefault);
-
-// var promptTask = this.promptHandlerContext.WaitForChoicePrompt();
-// var executeTask = this.powerShellContext.ExecuteScriptString(choiceScript);
-
-// // Wait for the prompt to be shown
-// var promptHandler = await promptTask;
-
-// // Respond to the prompt and wait for the prompt to complete
-// await promptHandler.ReturnInputString("apple");
-// await executeTask;
-
-// string[] outputLines =
-// this.GetOutputForType(OutputType.Normal)
-// .Split(
-// new string[] { Environment.NewLine },
-// StringSplitOptions.None);
-
-// Assert.Equal(PromptCaption, outputLines[0]);
-// Assert.Equal(PromptMessage, outputLines[1]);
-// Assert.Equal("[A] Apple [N] Banana [] Orange [?] Help (default is \"Banana\"): apple", outputLines[2]);
-// Assert.Equal("0", outputLines[3]);
-// }
-
-// [Fact]
-// public async Task CancelsChoicePrompt()
-// {
-// string choiceScript =
-// this.GetChoicePromptString(
-// PromptCaption,
-// PromptMessage,
-// PromptChoices,
-// PromptDefault);
-
-// var promptTask = this.promptHandlerContext.WaitForChoicePrompt();
-// var executeTask = this.powerShellContext.ExecuteScriptString(choiceScript);
-
-// // Wait for the prompt to be shown
-// await promptTask;
-
-// // Cancel the prompt and wait for the execution to complete
-// this.consoleService.SendControlC();
-// await executeTask;
-
-// string[] outputLines =
-// this.GetOutputForType(OutputType.Normal)
-// .Split(
-// new string[] { Environment.NewLine },
-// StringSplitOptions.None);
-
-// Assert.Equal(PromptCaption, outputLines[0]);
-// Assert.Equal(PromptMessage, outputLines[1]);
-// Assert.Equal("[A] Apple [N] Banana [] Orange [?] Help (default is \"Banana\"): ", outputLines[2]);
-// }
-
-// [Fact]
-// public async Task ReceivesChoicePromptHelp()
-// {
-// string choiceScript =
-// this.GetChoicePromptString(
-// PromptCaption,
-// PromptMessage,
-// PromptChoices,
-// PromptDefault);
-
-// var promptTask = this.promptHandlerContext.WaitForChoicePrompt();
-// var executeTask = this.powerShellContext.ExecuteScriptString(choiceScript);
-
-// // Wait for the prompt to be shown
-// var promptHandler = await promptTask;
-
-// // Respond to the prompt and wait for the help prompt to appear
-// await promptHandler.ReturnInputString("?");
-// await promptHandler.ReturnInputString("A");
-// await executeTask;
-
-// string[] outputLines =
-// this.GetOutputForType(OutputType.Normal)
-// .Split(
-// new string[] { Environment.NewLine },
-// StringSplitOptions.None);
-
-// // Help lines start after initial prompt, skip 3 lines
-// Assert.Equal("A - Help for Apple", outputLines[3]);
-// Assert.Equal("N - Help for Banana", outputLines[4]);
-// Assert.Equal("Orange - Help for Orange", outputLines[5]);
-// }
-
-// [Fact]
-// public async Task ReceivesInputPrompt()
-// {
-// string inputScript =
-// this.GetInputPromptString(
-// PromptCaption,
-// PromptMessage,
-// PromptFields);
-
-// var promptTask = this.promptHandlerContext.WaitForInputPrompt();
-// var executeTask = this.powerShellContext.ExecuteScriptString(inputScript);
-
-// // Wait for the prompt to be shown
-// var promptHandler = await promptTask;
-
-// // Respond to the prompt and wait for execution to complete
-// await promptHandler.ReturnInputString("John");
-// await promptHandler.ReturnInputString("40");
-// await promptHandler.ReturnInputString("Windows PowerShell In Action");
-// await promptHandler.ReturnInputString("");
-// await executeTask;
-
-// string[] outputLines =
-// this.GetOutputForType(OutputType.Normal)
-// .Split(
-// new string[] { Environment.NewLine },
-// StringSplitOptions.None);
-
-// Assert.Equal(PromptCaption, outputLines[0]);
-// Assert.Equal(PromptMessage, outputLines[1]);
-// Assert.Equal("Name: John", outputLines[2]);
-// Assert.Equal("Age: 40", outputLines[3]);
-// Assert.Equal("Books[0]: Windows PowerShell In Action", outputLines[4]);
-// Assert.Equal("Books[1]: ", outputLines[5]);
-// Assert.Equal("Name John", outputLines[9].Trim());
-// Assert.Equal("Age 40", outputLines[10].Trim());
-// Assert.Equal("Books {Windows PowerShell In Action}", outputLines[11].Trim());
-// }
-
-// [Fact]
-// public async Task CancelsInputPrompt()
-// {
-// string inputScript =
-// this.GetInputPromptString(
-// PromptCaption,
-// PromptMessage,
-// PromptFields);
-
-// var promptTask = this.promptHandlerContext.WaitForInputPrompt();
-// var executeTask = this.powerShellContext.ExecuteScriptString(inputScript);
-
-// // Wait for the prompt to be shown
-// await promptTask;
-
-// // Cancel the prompt and wait for execution to complete
-// this.consoleService.SendControlC();
-// await executeTask;
-
-// string[] outputLines =
-// this.GetOutputForType(OutputType.Normal)
-// .Split(
-// new string[] { Environment.NewLine },
-// StringSplitOptions.None);
-
-// Assert.Equal(PromptCaption, outputLines[0]);
-// Assert.Equal(PromptMessage, outputLines[1]);
-// Assert.Equal("Name: ", outputLines[2]);
-// }
-
-// [Fact]
-// public async Task ReceivesReadHostPrompt()
-// {
-// var promptTask = this.promptHandlerContext.WaitForInputPrompt();
-// var executeTask = this.powerShellContext.ExecuteScriptString("Read-Host");
-
-// // Wait for the prompt to be shown
-// TestConsoleInputPromptHandler promptHandler = await promptTask;
-
-// // Respond to the prompt and wait for execution to complete
-// await promptHandler.ReturnInputString("John");
-// await executeTask;
-
-// string[] outputLines =
-// this.GetOutputForType(OutputType.Normal)
-// .Split(
-// new string[] { Environment.NewLine },
-// StringSplitOptions.None);
-
-// Assert.Equal("John", outputLines[0]);
-// Assert.Equal("John", outputLines[1]);
-// }
-
-// [Fact]
-// public async Task CancelsReadHostPrompt()
-// {
-// var promptTask = this.promptHandlerContext.WaitForInputPrompt();
-// var executeTask = this.powerShellContext.ExecuteScriptString("Read-Host");
-
-// // Wait for the prompt to be shown
-// await promptTask;
-
-// // Cancel the prompt and wait for execution to complete
-// this.consoleService.SendControlC();
-// await executeTask;
-
-// // No output will be written from a cancelled Read-Host prompt
-// Assert.Null(this.GetOutputForType(OutputType.Normal));
-// }
-
-// [Fact]
-// public async Task ReceivesReadHostPromptWithFieldName()
-// {
-// var promptTask = this.promptHandlerContext.WaitForInputPrompt();
-// var executeTask = this.powerShellContext.ExecuteScriptString("Read-Host -Prompt \"Name\"");
-
-// // Wait for the prompt to be shown
-// TestConsoleInputPromptHandler promptHandler = await promptTask;
-
-// // Respond to the prompt and wait for execution to complete
-// await promptHandler.ReturnInputString("John");
-// await executeTask;
-
-// string[] outputLines =
-// this.GetOutputForType(OutputType.Normal)
-// .Split(
-// new string[] { Environment.NewLine },
-// StringSplitOptions.None);
-
-// Assert.Equal("Name: John", outputLines[0]);
-// Assert.Equal("John", outputLines[1]);
-// }
-
-// #region Helper Methods
-
-// void OnOutputWritten(object sender, OutputWrittenEventArgs e)
-// {
-// string storedOutputString = null;
-// if (!this.outputPerType.TryGetValue(e.OutputType, out storedOutputString))
-// {
-// this.outputPerType.Add(e.OutputType, null);
-// }
-
-// if (storedOutputString == null)
-// {
-// storedOutputString = e.OutputText;
-// }
-// else
-// {
-// storedOutputString += e.OutputText;
-// }
-
-// if (e.IncludeNewLine)
-// {
-// storedOutputString += Environment.NewLine;
-// }
-
-// this.outputPerType[e.OutputType] = storedOutputString;
-// }
-
-// private string GetOutputForType(OutputType outputLineType)
-// {
-// string outputString = null;
-
-// this.outputPerType.TryGetValue(outputLineType, out outputString);
-
-// return outputString;
-// }
-
-// private string GetChoicePromptString(
-// string caption,
-// string message,
-// Tuple[] choices,
-// int defaultChoice)
-// {
-// StringBuilder scriptBuilder = new StringBuilder();
-
-// scriptBuilder.AppendFormat(
-// "$caption = {0}\r\n",
-// caption != null ?
-// "\"" + caption + "\"" :
-// "$null");
-
-// scriptBuilder.AppendFormat(
-// "$message = {0}\r\n",
-// message != null ?
-// "\"" + message + "\"" :
-// "$null");
-
-// scriptBuilder.AppendLine("$choices = [System.Management.Automation.Host.ChoiceDescription[]](");
-
-// List choiceItems = new List();
-// foreach (var choice in choices)
-// {
-// choiceItems.Add(
-// string.Format(
-// " (new-Object System.Management.Automation.Host.ChoiceDescription \"{0}\",\"{1}\")",
-// choice.Item1,
-// choice.Item2));
-// }
-
-// scriptBuilder.AppendFormat(
-// "{0})\r\n",
-// string.Join(",\r\n", choiceItems));
-
-// scriptBuilder.AppendFormat(
-// "$host.ui.PromptForChoice($caption, $message, $choices, {0})\r\n",
-// defaultChoice);
-
-// return scriptBuilder.ToString();
-// }
-
-// private string GetInputPromptString(
-// string caption,
-// string message,
-// Tuple[] fields)
-// {
-// StringBuilder scriptBuilder = new StringBuilder();
-
-// scriptBuilder.AppendFormat(
-// "$caption = {0}\r\n",
-// caption != null ?
-// "\"" + caption + "\"" :
-// "$null");
-
-// scriptBuilder.AppendFormat(
-// "$message = {0}\r\n",
-// message != null ?
-// "\"" + message + "\"" :
-// "$null");
-
-// foreach (var field in fields)
-// {
-// scriptBuilder.AppendFormat(
-// "${0}Field = New-Object System.Management.Automation.Host.FieldDescription \"{0}\"\r\n${0}Field.SetParameterType([{1}])\r\n",
-// field.Item1,
-// field.Item2.FullName);
-// }
-
-// scriptBuilder.AppendFormat(
-// "$fields = [System.Management.Automation.Host.FieldDescription[]]({0})\r\n",
-// string.Join(
-// ", ",
-// fields.Select(
-// f => string.Format("${0}Field", f.Item1))));
-
-// scriptBuilder.AppendLine(
-// "$host.ui.Prompt($caption, $message, $fields)");
-
-// return scriptBuilder.ToString();
-// }
-
-// #endregion
-// }
-
-// internal class TestConsolePromptHandlerContext : IPromptHandlerContext
-// {
-// private TaskCompletionSource choicePromptShownTask;
-// private TaskCompletionSource inputPromptShownTask;
-
-// public IHostOutput ConsoleHost { get; set; }
-
-// public ChoicePromptHandler GetChoicePromptHandler()
-// {
-// return new TestConsoleChoicePromptHandler(
-// this.ConsoleHost,
-// this.choicePromptShownTask);
-// }
-
-// public InputPromptHandler GetInputPromptHandler()
-// {
-// return new TestConsoleInputPromptHandler(
-// this.ConsoleHost,
-// this.inputPromptShownTask);
-// }
-
-// public Task WaitForChoicePrompt()
-// {
-// this.choicePromptShownTask = new TaskCompletionSource();
-// return this.choicePromptShownTask.Task;
-// }
-
-// public Task WaitForInputPrompt()
-// {
-// this.inputPromptShownTask = new TaskCompletionSource();
-// return this.inputPromptShownTask.Task;
-// }
-// }
-
-// internal class TestConsoleChoicePromptHandler : ConsoleChoicePromptHandler
-// {
-// private IHostOutput hostOutput;
-// private TaskCompletionSource promptShownTask;
-// private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
-
-// private TaskCompletionSource linePromptTask;
-// private AsyncQueue> linePromptQueue =
-// new AsyncQueue>();
-
-// public TestConsoleChoicePromptHandler(
-// IHostOutput hostOutput,
-// TaskCompletionSource promptShownTask)
-// : base(hostOutput)
-// {
-// this.hostOutput = hostOutput;
-// this.promptShownTask = promptShownTask;
-// }
-
-// public async Task ReturnInputString(string inputString)
-// {
-// var promptTask = await this.linePromptQueue.DequeueAsync();
-// this.hostOutput.WriteOutput(inputString);
-// promptTask.SetResult(inputString);
-// }
-
-// protected override async Task ReadInputString(CancellationToken cancellationToken)
-// {
-// TaskCompletionSource promptTask = new TaskCompletionSource();
-// await this.linePromptQueue.EnqueueAsync(promptTask);
-
-// if (this.cancellationTokenSource.IsCancellationRequested)
-// {
-// this.linePromptTask.TrySetCanceled();
-// }
-
-// this.linePromptTask = promptTask;
-// return await promptTask.Task;
-// }
-
-// protected override void ShowPrompt(PromptStyle promptStyle)
-// {
-// base.ShowPrompt(promptStyle);
-
-// if (this.promptShownTask != null &&
-// this.promptShownTask.Task.Status != TaskStatus.RanToCompletion)
-// {
-// this.promptShownTask.SetResult(this);
-// }
-// }
-
-// protected override void OnPromptCancelled()
-// {
-// this.cancellationTokenSource.Cancel();
-
-// if (this.linePromptTask != null)
-// {
-// this.linePromptTask.TrySetCanceled();
-// }
-// }
-// }
-
-// internal class TestConsoleInputPromptHandler : ConsoleInputPromptHandler
-// {
-// private IHostOutput hostOutput;
-// private TaskCompletionSource promptShownTask;
-// private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
-
-// private TaskCompletionSource linePromptTask;
-// private AsyncQueue> linePromptQueue =
-// new AsyncQueue>();
-
-// public TestConsoleInputPromptHandler(
-// IHostOutput hostOutput,
-// TaskCompletionSource promptShownTask)
-// : base(hostOutput)
-// {
-// this.hostOutput = hostOutput;
-// this.promptShownTask = promptShownTask;
-// }
-
-// public async Task ReturnInputString(string inputString)
-// {
-// var promptTask = await this.linePromptQueue.DequeueAsync();
-// this.hostOutput.WriteOutput(inputString);
-// promptTask.SetResult(inputString);
-// }
-
-// protected override async Task ReadInputString(CancellationToken cancellationToken)
-// {
-// TaskCompletionSource promptTask = new TaskCompletionSource();
-// await this.linePromptQueue.EnqueueAsync(promptTask);
-
-// if (this.cancellationTokenSource.IsCancellationRequested)
-// {
-// this.linePromptTask.TrySetCanceled();
-// }
-
-// this.linePromptTask = promptTask;
-// return await promptTask.Task;
-// }
-
-// protected override void ShowFieldPrompt(FieldDetails fieldDetails)
-// {
-// base.ShowFieldPrompt(fieldDetails);
-
-// // Raise the task for the first field prompt shown
-// if (this.promptShownTask != null &&
-// this.promptShownTask.Task.Status == TaskStatus.WaitingForActivation)
-// {
-// this.promptShownTask.SetResult(this);
-// }
-// }
-
-// protected override void OnPromptCancelled()
-// {
-// this.cancellationTokenSource.Cancel();
-
-// if (this.linePromptTask != null)
-// {
-// this.linePromptTask.TrySetCanceled();
-// }
-// }
-// }
-// }
\ No newline at end of file
diff --git a/test/PowerShellEditorServices.Test/Console/InputPromptHandlerTests.cs b/test/PowerShellEditorServices.Test/Console/InputPromptHandlerTests.cs
index 689ae1c8b..9f4bb6a5d 100644
--- a/test/PowerShellEditorServices.Test/Console/InputPromptHandlerTests.cs
+++ b/test/PowerShellEditorServices.Test/Console/InputPromptHandlerTests.cs
@@ -3,7 +3,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Microsoft.PowerShell.EditorServices.Console;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -11,7 +10,8 @@
using System;
using System.Threading;
using System.Security;
-using Microsoft.PowerShell.EditorServices.Utility;
+using Microsoft.PowerShell.EditorServices.Services.PowerShellContext;
+using Microsoft.Extensions.Logging.Abstractions;
namespace Microsoft.PowerShell.EditorServices.Test.Console
{
@@ -34,8 +34,9 @@ public class InputPromptHandlerTests
new CollectionFieldDetails(BooksField, "Favorite Books", typeof(IList), false, null)
};
+ [Trait("Category", "Prompt")]
[Fact]
- public void InputPromptHandlerReturnsValuesOfCorrectType()
+ public async Task InputPromptHandlerReturnsValuesOfCorrectType()
{
TestInputPromptHandler inputPromptHandler = new TestInputPromptHandler();
Task> promptTask =
@@ -46,17 +47,17 @@ public void InputPromptHandlerReturnsValuesOfCorrectType()
CancellationToken.None);
Assert.Equal(NameField, inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString(NameValue);
+ await inputPromptHandler.ReturnInputString(NameValue).ConfigureAwait(false);
Assert.Equal(AgeField, inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString(AgeValue.ToString());
+ await inputPromptHandler.ReturnInputString(AgeValue.ToString()).ConfigureAwait(false);
Assert.Equal(BooksField + "[0]", inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString((string)BookItems[0]);
+ await inputPromptHandler.ReturnInputString((string)BookItems[0]).ConfigureAwait(false);
Assert.Equal(BooksField + "[1]", inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString((string)BookItems[1]);
+ await inputPromptHandler.ReturnInputString((string)BookItems[1]).ConfigureAwait(false);
Assert.Equal(BooksField + "[2]", inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString("");
+ await inputPromptHandler.ReturnInputString("").ConfigureAwait(false);
// Make sure the right results are returned
Assert.Equal(TaskStatus.RanToCompletion, promptTask.Status);
@@ -66,8 +67,9 @@ public void InputPromptHandlerReturnsValuesOfCorrectType()
Assert.Equal(BookItems, fieldValues[BooksField]);
}
+ [Trait("Category", "Prompt")]
[Fact]
- public void InputPromptHandlerAcceptsArrayOfNonStringValues()
+ public async Task InputPromptHandlerAcceptsArrayOfNonStringValues()
{
TestInputPromptHandler inputPromptHandler = new TestInputPromptHandler();
Task> promptTask =
@@ -81,8 +83,8 @@ public void InputPromptHandlerAcceptsArrayOfNonStringValues()
CancellationToken.None);
Assert.Equal("Numbers[0]", inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString("1");
- inputPromptHandler.ReturnInputString("");
+ await inputPromptHandler.ReturnInputString("1").ConfigureAwait(false);
+ await inputPromptHandler.ReturnInputString("").ConfigureAwait(false);
// Make sure the right results are returned
Assert.Equal(TaskStatus.RanToCompletion, promptTask.Status);
@@ -90,8 +92,9 @@ public void InputPromptHandlerAcceptsArrayOfNonStringValues()
Assert.Equal(new int[] { 1 }, fieldValues["Numbers"]);
}
+ [Trait("Category", "Prompt")]
[Fact]
- public void InputPromptRetriesWhenCannotCastValue()
+ public async Task InputPromptRetriesWhenCannotCastValue()
{
TestInputPromptHandler inputPromptHandler = new TestInputPromptHandler();
Task> promptTask =
@@ -102,19 +105,19 @@ public void InputPromptRetriesWhenCannotCastValue()
CancellationToken.None);
Assert.Equal(NameField, inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString(NameValue);
+ await inputPromptHandler.ReturnInputString(NameValue).ConfigureAwait(false);
// Intentionally give a non-integer string to cause an error
Assert.Equal(AgeField, inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString(NameValue);
+ await inputPromptHandler.ReturnInputString(NameValue).ConfigureAwait(false);
Assert.NotNull(inputPromptHandler.LastError);
// Give the right value the next time
Assert.Equal(AgeField, inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString(AgeValue.ToString());
+ await inputPromptHandler.ReturnInputString(AgeValue.ToString()).ConfigureAwait(false);
Assert.Equal(BooksField + "[0]", inputPromptHandler.LastField.Name);
- inputPromptHandler.ReturnInputString("");
+ await inputPromptHandler.ReturnInputString("").ConfigureAwait(false);
// Make sure the right results are returned
Assert.Equal(TaskStatus.RanToCompletion, promptTask.Status);
@@ -132,13 +135,17 @@ internal class TestInputPromptHandler : InputPromptHandler
public Exception LastError { get; private set; }
- public TestInputPromptHandler() : base(Logging.NullLogger)
+ public TestInputPromptHandler() : base(NullLogger.Instance)
{
}
- public void ReturnInputString(string inputString)
+ public Task ReturnInputString(string inputString)
{
this.linePromptTask.SetResult(inputString);
+
+ // TODO: refactor tests to not need this Delay. There seems to be a race condition
+ // in how this test cleans up after SetResult is run.
+ return Task.Delay(100);
}
public void ReturnSecureString(SecureString secureString)
@@ -173,4 +180,3 @@ protected override void ShowErrorMessage(Exception e)
}
}
}
-
diff --git a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs
index fe88e7fd8..c6915186f 100644
--- a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs
+++ b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs
@@ -1,1005 +1,1046 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-using Microsoft.PowerShell.EditorServices.Debugging;
-using Microsoft.PowerShell.EditorServices.Utility;
-using Microsoft.PowerShell.EditorServices.Test.Shared;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Management.Automation;
-using System.Threading;
-using System.Threading.Tasks;
-using Xunit;
-
-namespace Microsoft.PowerShell.EditorServices.Test.Debugging
-{
- public class DebugServiceTests : IDisposable
- {
- private Workspace workspace;
- private DebugService debugService;
- private ScriptFile debugScriptFile;
- private ScriptFile variableScriptFile;
- private PowerShellContext powerShellContext;
- private SynchronizationContext runnerContext;
-
- private AsyncQueue debuggerStoppedQueue =
- new AsyncQueue();
- private AsyncQueue sessionStateQueue =
- new AsyncQueue();
-
- public DebugServiceTests()
- {
- var logger = Logging.NullLogger;
-
- this.powerShellContext = PowerShellContextFactory.Create(logger);
- this.powerShellContext.SessionStateChanged += powerShellContext_SessionStateChanged;
-
- this.workspace = new Workspace(this.powerShellContext.LocalPowerShellVersion.Version, logger);
-
- // Load the test debug file
- this.debugScriptFile =
- this.workspace.GetFile(
- TestUtilities.NormalizePath("../../../../PowerShellEditorServices.Test.Shared/Debugging/VariableTest.ps1"));
-
- this.variableScriptFile =
- this.workspace.GetFile(
- TestUtilities.NormalizePath("../../../../PowerShellEditorServices.Test.Shared/Debugging/VariableTest.ps1"));
-
- this.debugService = new DebugService(this.powerShellContext, logger);
- this.debugService.DebuggerStopped += debugService_DebuggerStopped;
- this.debugService.BreakpointUpdated += debugService_BreakpointUpdated;
- this.runnerContext = SynchronizationContext.Current;
-
- // Load the test debug file
- this.debugScriptFile =
- this.workspace.GetFile(
- TestUtilities.NormalizePath("../../../../PowerShellEditorServices.Test.Shared/Debugging/DebugTest.ps1"));
- }
-
- async void powerShellContext_SessionStateChanged(object sender, SessionStateChangedEventArgs e)
- {
- // Skip all transitions except those back to 'Ready'
- if (e.NewSessionState == PowerShellContextState.Ready)
- {
- await this.sessionStateQueue.EnqueueAsync(e);
- }
- }
-
- void debugService_BreakpointUpdated(object sender, BreakpointUpdatedEventArgs e)
- {
- // TODO: Needed?
- }
-
- void debugService_DebuggerStopped(object sender, DebuggerStoppedEventArgs e)
- {
- // We need to ensure this is run on a different thread than the one it's
- // called on because it can cause PowerShellContext.OnDebuggerStopped to
- // never hit the while loop.
- Task.Run(() => this.debuggerStoppedQueue.Enqueue(e));
- }
-
- public void Dispose()
- {
- this.powerShellContext.Dispose();
- }
-
- public static IEnumerable