-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from StormHub/Poll
Migrate Poll tests. #4
- Loading branch information
Showing
4 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Johnny Z. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace NetUV.Core.Tests | ||
{ | ||
using System; | ||
using System.IO; | ||
using NetUV.Core.Handles; | ||
using NetUV.Core.Native; | ||
using Xunit; | ||
|
||
public sealed class PollTests : IDisposable | ||
{ | ||
Loop loop; | ||
IDisposable fdHandle; | ||
|
||
public PollTests() | ||
{ | ||
this.loop = new Loop(); | ||
} | ||
|
||
[Fact] | ||
public void BadFileDescriptorType() | ||
{ | ||
FileStream file = TestHelper.OpenTempFile(); | ||
this.fdHandle = file; | ||
|
||
IntPtr handle = file.SafeFileHandle.DangerousGetHandle(); | ||
var error = Assert.Throws<OperationException>(() => this.loop.CreatePoll(handle.ToInt32())); | ||
file.Dispose(); | ||
|
||
Assert.Equal((int)uv_err_code.UV_ENOTSOCK, error.ErrorCode); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
this.fdHandle?.Dispose(); | ||
this.fdHandle = null; | ||
|
||
this.loop?.Dispose(); | ||
this.loop = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters