Test LibuvConstants.IsConnectionReset

This commit is contained in:
Stephen Halter 2018-10-04 15:40:09 -07:00
parent df2ad98743
commit b3f9f38ac6
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal;
using Xunit;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
{
public class LibuvConstantsTests
{
[Fact]
public void IsConnectionResetReturnsTrueForExpectedLibuvErrorConstants()
{
// All the below constants are defined on all supported platforms (Windows, Linux, macOS)
Assert.True(LibuvConstants.IsConnectionReset(LibuvConstants.ECONNRESET.Value));
Assert.True(LibuvConstants.IsConnectionReset(LibuvConstants.EPIPE.Value));
Assert.True(LibuvConstants.IsConnectionReset(LibuvConstants.ENOTCONN.Value));
Assert.True(LibuvConstants.IsConnectionReset(LibuvConstants.EINVAL.Value));
// All libuv error constants are negative on all platforms.
Assert.False(LibuvConstants.IsConnectionReset(0));
}
}
}