本文整理汇总了C#中DateTimeOffset.ShouldBe方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeOffset.ShouldBe方法的具体用法?C# DateTimeOffset.ShouldBe怎么用?C# DateTimeOffset.ShouldBe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeOffset
的用法示例。
在下文中一共展示了DateTimeOffset.ShouldBe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DateTimeOffsetScenarioShouldFail
public void DateTimeOffsetScenarioShouldFail()
{
var date = new DateTimeOffset(new DateTime(2000, 6, 1), TimeSpan.Zero);
var dateString = date.ToString();
var exptected = new DateTimeOffset(new DateTime(2000, 6, 1, 1, 0, 1), TimeSpan.Zero);
var expectedDate = exptected.ToString();
Verify.ShouldFail(() =>
date.ShouldBe(exptected, TimeSpan.FromHours(1), "Some additional context"),
errorWithSource:
[email protected]"date
should be within
01:00:00
of
{expectedDate}
but was
{dateString}
Additional Info:
Some additional context",
errorWithoutSource:
[email protected]"{dateString}
should be within
01:00:00
of
{expectedDate}
but was not
Additional Info:
Some additional context");
}
示例2: ShouldPass
public void ShouldPass()
{
var date = new DateTimeOffset(new DateTime(2000, 6, 1), TimeSpan.Zero);
date.ShouldBe(new DateTimeOffset(new DateTime(2000, 6, 1, 1, 0, 1), TimeSpan.Zero), TimeSpan.FromHours(1.5));
}
示例3: ShouldThrowAWobbly
protected override void ShouldThrowAWobbly()
{
var date = new DateTimeOffset(new DateTime(2000, 6, 1), TimeSpan.Zero);
date.ShouldBe(new DateTimeOffset(new DateTime(2000, 6, 1, 1, 0, 1), TimeSpan.Zero), TimeSpan.FromHours(1));
}