Skip to content

Commit

Permalink
Add tests for round trip serializing TimeZoneInfos. (dotnet/corefx#40637
Browse files Browse the repository at this point in the history
)

Fix dotnet/corefx#40578

Commit migrated from dotnet/corefx@75a591d
  • Loading branch information
Eric Erhardt committed Aug 31, 2019
1 parent 6b9fc1c commit a9c3275
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.RegularExpressions;
using Xunit;

namespace System.Tests
Expand Down Expand Up @@ -2164,6 +2165,22 @@ public static void ToSerializedString_FromSerializedString_RoundTrips(TimeZoneIn
Assert.Equal(serialized, deserializedTimeZone.ToSerializedString());
}

[Theory]
[MemberData(nameof(SystemTimeZonesTestData))]
public static void BinaryFormatter_RoundTrips(TimeZoneInfo timeZone)
{
BinaryFormatter formatter = new BinaryFormatter();

using (MemoryStream stream = new MemoryStream())
{
formatter.Serialize(stream, timeZone);
stream.Position = 0;

TimeZoneInfo deserializedTimeZone = (TimeZoneInfo)formatter.Deserialize(stream);
Assert.Equal(timeZone, deserializedTimeZone);
}
}

[Fact]
public static void TimeZoneInfo_DoesNotCreateAdjustmentRulesWithOffsetOutsideOfRange()
{
Expand Down

0 comments on commit a9c3275

Please sign in to comment.