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