-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerializeGermanTimezoneInfo.cs
35 lines (32 loc) · 1.17 KB
/
SerializeGermanTimezoneInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using FluentAssertions;
using MaLoIdentModels.Validation;
namespace MaLoIdentModelsTests.v1Tests;
public class CreateTimeZoneFile
{
/// <summary>
/// saves the German timezone to a serialized string: https://learn.microsoft.com/en-us/dotnet/standard/datetime/save-time-zones-to-an-embedded-resource#example
/// </summary>
[Fact]
public void Serialized_Timezoneinfo_Is_Actual_German_Timezone()
{
TimeZoneInfo tzi;
try
{
tzi = TimeZoneInfo.FindSystemTimeZoneById("Central Europe Standard Time");
}
catch (TimeZoneNotFoundException)
{
//Assert.IsTrue(false, "You cannot use this method on your machine."); // this occurs in github actions. it's ok.
return;
}
tzi.SupportsDaylightSavingTime.Should().BeTrue();
var expected = tzi.ToSerializedString();
GermanMidnightValidationAttribute.GermanTimeZoneSerializedAsString.Should().Be(expected);
TimeZoneInfo
.FromSerializedString(
GermanMidnightValidationAttribute.GermanTimeZoneSerializedAsString
)
.Should()
.BeEquivalentTo(tzi);
}
}