From b3f9f38ac6200193ae7f018ca1a7d8af4006b870 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Thu, 4 Oct 2018 15:40:09 -0700 Subject: [PATCH] Test LibuvConstants.IsConnectionReset --- .../LibuvConstantsTests.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/Kestrel.Transport.Libuv.Tests/LibuvConstantsTests.cs diff --git a/test/Kestrel.Transport.Libuv.Tests/LibuvConstantsTests.cs b/test/Kestrel.Transport.Libuv.Tests/LibuvConstantsTests.cs new file mode 100644 index 0000000000..6ff5920fdd --- /dev/null +++ b/test/Kestrel.Transport.Libuv.Tests/LibuvConstantsTests.cs @@ -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)); + } + } +}