-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathTimeZoneInfoMockerTests.cs
More file actions
31 lines (27 loc) · 1.03 KB
/
TimeZoneInfoMockerTests.cs
File metadata and controls
31 lines (27 loc) · 1.03 KB
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
using System;
using System.Collections.Generic;
using Xunit;
using NetCoreForce.Client;
using NetCoreForce.Client.Models;
namespace NetCoreForce.Client.Tests
{
public class TimeZoneInfoMockerTests
{
[Fact]
public void TestLocalTimeZoneInfoMocker()
{
TimeSpan mockedUtcOffset;
TimeSpan actualLocalUtcOffset = TimeZoneInfo.Local.BaseUtcOffset;
using (new LocalTimeZoneInfoMocker(TimeZoneInfo.FindSystemTimeZoneById(TimeZoneIds.TimeZoneIdPhoenix)))
{
// shifted to Phoenix TZ
Assert.Equal(TimeZoneIds.TimeZoneIdPhoenix, TimeZoneInfo.Local.Id);
mockedUtcOffset = TimeZoneInfo.Local.BaseUtcOffset;
Assert.NotEqual(TimeZoneInfo.Local.BaseUtcOffset, actualLocalUtcOffset);
}
// back to local machine's TZ
Assert.NotEqual(TimeZoneInfo.Local.Id, TimeZoneIds.TimeZoneIdPhoenix);
Assert.NotEqual(TimeZoneInfo.Local.BaseUtcOffset, mockedUtcOffset);
}
}
}