Skip to content
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

added spec to verify default CTOR argument serialization is broken #38

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all 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
29 changes: 29 additions & 0 deletions Hyperion.Tests/CustomObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ private class PrivateType
{
public int IntProp { get; set; }
}

private class DefaultArgumentCtorType
{
public DefaultArgumentCtorType(bool val1 = false, bool val2 = false)
{
Val1 = val1;
Val2 = val2;
}

public bool Val1 { get; }

public bool Val2 { get; }
}

[Fact]
public void CanSerializePrivateType()
{
Expand Down Expand Up @@ -56,6 +70,21 @@ public void CanSerializeNull()
Assert.Equal(expected, actual);
}

[InlineData(true, false)]
[InlineData(false, false)]
[InlineData(true, true)]
[InlineData(false, true)]
[Theory]
public void CanSerializeDefaultCtorArguments(bool val1, bool val2)
{
// need at least 1 value to be non-default
var expected = new DefaultArgumentCtorType(val1, val2);
Serialize(expected);
Reset();
var actual = Deserialize<DefaultArgumentCtorType>();
Assert.Equal(expected.Val1, actual.Val1);
Assert.Equal(expected.Val2, actual.Val1);
}

//this uses a lightweight serialization of exceptions to conform to .NET core's lack of ISerializable
//all custom exception information will be lost.
Expand Down