-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add unit tests for SingleInstanceHelper and fix formatting from simplifying PR #11863 #12261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lonitra
merged 19 commits into
dotnet:main
from
paul1956:FIx-Formatting-in-SingleInstanceHelper-From-#11863
Oct 11, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4c61c63
No code Chnages just formatting
paul1956 a4224c5
Add tests for SignleInstanceHelper from #11863
paul1956 2b5f268
Moved to SDK RC2 (#12254)
Tanya-Solyanik 1bcf239
Adds XML Comments to FileSystemProxy and SpecialDirectoriesProxy (#12…
paul1956 b4f93e3
[main] Update dependencies from dotnet/runtime (#12266)
dotnet-maestro[bot] 756e030
Fix IDE0002 in LogTests.cs (#12265)
paul1956 0267546
[main] Update dependencies from dotnet/arcade (#12271)
dotnet-maestro[bot] d049e5c
[main] Update dependencies from dotnet/runtime (#12272)
dotnet-maestro[bot] d90caed
Improve code coverage for FileLogTraceListener from simplifying PR #1…
paul1956 a629958
Switch default feed to use wildcards only (#12268)
richlander 03cb5dd
Move local closer to usage
paul1956 b487081
Merge branch 'master' into FIx-Formatting-in-SingleInstanceHelper-Fro…
paul1956 6887976
Merge branch 'master' into FIx-Formatting-in-SingleInstanceHelper-Fro…
paul1956 0119ea3
PR Feedback
paul1956 a15c1ee
Merge branch 'master' into FIx-Formatting-in-SingleInstanceHelper-Fro…
paul1956 a82f402
Address PR Feedback
paul1956 a278a8b
PR Feedback
paul1956 ef78e8c
PR Feedback inline private Sub, reuse commandLine
paul1956 02c975c
Merge branch 'master' into FIx-Formatting-in-SingleInstanceHelper-Fro…
paul1956 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
84 changes: 84 additions & 0 deletions
84
...soft.VisualBasic.Forms/tests/UnitTests/System/Windows/Forms/SingleInstanceHelpersTests.vb
This file contains hidden or 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,84 @@ | ||
| ' Licensed to the .NET Foundation under one or more agreements. | ||
| ' The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| Imports System.IO.Pipes | ||
| Imports System.Runtime.CompilerServices | ||
| Imports System.Threading | ||
| Imports FluentAssertions | ||
| Imports Microsoft.VisualBasic.ApplicationServices | ||
|
|
||
| Imports Xunit | ||
|
|
||
| Namespace Microsoft.VisualBasic.Forms.Tests | ||
|
|
||
| Public Class SingleInstanceHelpersTests | ||
| Private _resultArgs As String() | ||
|
|
||
| <WinFormsFact> | ||
| Public Sub TryCreatePipeServerTests() | ||
| Dim pipeName As String = GetUniqueText() | ||
| Dim pipeServer As NamedPipeServerStream = Nothing | ||
| TryCreatePipeServer(pipeName, pipeServer).Should.BeTrue() | ||
| Using pipeServer | ||
| pipeServer.CanRead.Should.BeTrue() | ||
| pipeServer.CanSeek.Should.BeFalse() | ||
| pipeServer.CanWrite.Should.BeFalse() | ||
| pipeServer.TransmissionMode.Should.Be(PipeTransmissionMode.Byte) | ||
| End Using | ||
| End Sub | ||
|
|
||
| <WinFormsFact> | ||
| Public Sub TryCreatePipeServerTwiceTests_Fail() | ||
| Dim pipeName As String = GetUniqueText() | ||
| Dim pipeServer As NamedPipeServerStream = Nothing | ||
| TryCreatePipeServer(pipeName, pipeServer).Should.BeTrue() | ||
| Using pipeServer | ||
| Dim pipeServer1 As NamedPipeServerStream = Nothing | ||
| TryCreatePipeServer(pipeName, pipeServer1).Should.BeFalse() | ||
| pipeServer1.Should.BeNull() | ||
| End Using | ||
| End Sub | ||
|
|
||
| <WinFormsFact> | ||
| Public Async Function WaitForClientConnectionsAsyncTests() As Task | ||
| Dim pipeName As String = GetUniqueText() | ||
| Dim pipeServer As NamedPipeServerStream = Nothing | ||
|
|
||
| If TryCreatePipeServer(pipeName, pipeServer) Then | ||
|
|
||
| Using pipeServer | ||
| Dim tokenSource As New CancellationTokenSource() | ||
| Dim commandLine As String() = {"Hello"} | ||
| Dim clientConnection As Task = WaitForClientConnectionsAsync( | ||
| pipeServer, | ||
| callback:=Sub(args As String()) | ||
| If args.Length = 1 Then | ||
| _resultArgs = commandLine | ||
| End If | ||
| End Sub, | ||
| cancellationToken:=tokenSource.Token) | ||
|
|
||
| Dim awaitable As ConfiguredTaskAwaitable = SendSecondInstanceArgsAsync( | ||
| pipeName, | ||
| args:=commandLine, | ||
| cancellationToken:=tokenSource.Token) _ | ||
| .ConfigureAwait(continueOnCapturedContext:=False) | ||
|
|
||
| awaitable.GetAwaiter().GetResult() | ||
| Dim CancelToken As New CancellationToken | ||
| Dim buffer As Byte() = New Byte(commandLine.Length) {} | ||
| Dim count As Integer = Await pipeServer.ReadAsync( | ||
| buffer:=buffer.AsMemory(start:=0, length:=commandLine.Length)) | ||
|
|
||
| ' Ensure the result is set | ||
| Do | ||
| Await Task.Delay(5) | ||
| Loop Until _resultArgs IsNot Nothing | ||
| _resultArgs(0).Should.Be("Hello") | ||
| Await tokenSource.CancelAsync() | ||
| End Using | ||
| End If | ||
| End Function | ||
|
|
||
| End Class | ||
| End Namespace | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.