本文整理汇总了C#中Post.ToOutputFormat方法的典型用法代码示例。如果您正苦于以下问题:C# Post.ToOutputFormat方法的具体用法?C# Post.ToOutputFormat怎么用?C# Post.ToOutputFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post.ToOutputFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToOutputFormat_returns_correct_grammar_for_post_one_minute_ago
public void ToOutputFormat_returns_correct_grammar_for_post_one_minute_ago()
{
string testMessage = "Everything may or may not be awesome";
Post postOneMinuteAgo = new Post
{
Content = testMessage,
PostedDateTime = DateTime.UtcNow.AddMinutes(-1)
};
Assert.AreEqual($"{testMessage} (1 minute ago)", postOneMinuteAgo.ToOutputFormat());
}
示例2: ToOutPutFormat_returns_appropriate_time_units
public void ToOutPutFormat_returns_appropriate_time_units()
{
string testMessageSeconds = "Good morning world";
string testMessageMinutes = "Good night world";
string testMessageHours = "Good afternoon world";
string testMessageDays = "Good evening world";
Post testPostSeconds = new Post
{
Content = testMessageSeconds,
PostedDateTime = DateTime.UtcNow.AddSeconds(-5)
};
Assert.AreEqual($"{testMessageSeconds} (5 seconds ago)", testPostSeconds.ToOutputFormat());
Post testPostMinutes = new Post
{
Content = testMessageMinutes,
PostedDateTime = DateTime.UtcNow.AddMinutes(-7)
};
Assert.AreEqual($"{testMessageMinutes} (7 minutes ago)", testPostMinutes.ToOutputFormat());
Post testPostHours = new Post
{
Content = testMessageHours,
PostedDateTime = DateTime.UtcNow.AddHours(-1)
};
Assert.AreEqual($"{testMessageHours} (1 hour ago)", testPostHours.ToOutputFormat());
Post testPostDays = new Post
{
Content = testMessageDays,
PostedDateTime = DateTime.UtcNow.AddDays(-9)
};
Assert.AreEqual($"{testMessageDays} (9 days ago)", testPostDays.ToOutputFormat());
}
示例3: ToOutputFormat_returns_output_friendly_Post
public void ToOutputFormat_returns_output_friendly_Post()
{
string testMessage = "Everything is awesome";
Post testPost = new Post(testMessage);
Assert.AreEqual($"{testMessage} (0 seconds ago)", testPost.ToOutputFormat());
}