Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public void SetCookies(System.Uri uri, string cookieHeader) { }
public partial class CookieException : System.FormatException, System.Runtime.Serialization.ISerializable
{
public CookieException() { }
public CookieException(string? message) { }
public CookieException(string? message, System.Exception? innerException) { }
[System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
protected CookieException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ public CookieException() : base()
{
}

internal CookieException(string? message) : base(message)
/// <summary>
/// Initializes a new instance of the <see cref='CookieException'/> class with the specified error message.
/// </summary>
/// <param name="message">A <see cref="string"/> that describes the error that occurred.</param>
public CookieException(string? message) : base(message)
{
}

internal CookieException(string? message, Exception? inner) : base(message, inner)
/// <summary>
/// Initializes a new instance of the <see cref='CookieException'/> class with the specified error message
/// and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">A <see cref="string"/> that describes the error that occurred.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public CookieException(string? message, Exception? innerException) : base(message, innerException)
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Xunit;

namespace System.Net.Primitives.UnitTests.Tests;

public sealed class CookieExceptionTest
{
[Theory]
[InlineData("Testing the CookieException")]
[InlineData(null)]
public void Constructor_Message(string? message)
{
var exception = new CookieException(message);
Assert.Equal(message, exception.Message);
}

[Theory]
[InlineData("Testing the CookieException", true)]
[InlineData("Testing the CookieException", false)]
[InlineData(null, true)]
[InlineData(null, false)]
public void Constructor_Message_InnerException(string? message, bool innerException)
{
var inner = innerException ? new Exception() : null;
var exception = new CookieException(message, inner);

Assert.Equal(message, exception.Message);
Assert.Equal(inner, exception.InnerException);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace System.Net
public class CookieException : FormatException
{
public CookieException() : base() { }
internal CookieException(string message) : base(message) { }
internal CookieException(string message, Exception inner) : base(message, inner) { }
public CookieException(string message) : base(message) { }
public CookieException(string message, Exception inner) : base(message, inner) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<DefaultReferenceExclusion Include="System.Net.Primitives" />
</ItemGroup>
<ItemGroup>
<Compile Include="CookieExceptionTest.cs" />
<Compile Include="CookieInternalTest.cs" />
<Compile Include="CookieContainerTest.cs" />
<Compile Include="..\..\src\System\Net\CookieCollection.cs"
Expand Down
Loading