本文整理汇总了C#中User.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# User.Publish方法的具体用法?C# User.Publish怎么用?C# User.Publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.Publish方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OutputsPostsInDescendingTimestampOrder
public void OutputsPostsInDescendingTimestampOrder()
{
var alice = new User("Alice");
var bob = new User("Bob");
var charlie = new User("Charlie");
alice.Follow(bob);
alice.Follow(charlie);
var posts = new[]
{
new Post(bob, "Hello, world!", DateTime.MinValue),
new Post(charlie, "Bonjour la monde!", DateTime.MinValue.AddYears(1)),
new Post(bob, "Sekai, konnichiwa!", DateTime.MinValue.AddYears(2))
};
bob.Publish(posts[0]);
bob.Publish(posts[2]);
charlie.Publish(posts[1]);
var outputSpy = new OutputSpy();
var postFormatter = new PostFormatterDummy(p => p.Message);
var command = new PrintWall(postFormatter, outputSpy);
command.Execute(alice);
Assert.Equal(
new[] { "Sekai, konnichiwa!", "Bonjour la monde!", "Hello, world!" },
outputSpy.CalledWith);
}
示例2: PrintsTheFormattedStrings
public void PrintsTheFormattedStrings()
{
var user = new User("Alice");
user.Publish(new Post(user, "", DateTime.Now));
var spy = new OutputSpy();
var command = new PrintPosts(new PostFormatterDummy("Hello, World!"), spy);
command.Execute(user);
Assert.Equal(new[] { "Hello, World!" }, spy.CalledWith);
}
示例3: PrintsInDescendingTimestampOrder
public void PrintsInDescendingTimestampOrder()
{
var user = new User("Alice");
var posts = new[]
{
new Post(user, "Hello, world!", DateTime.MinValue),
new Post(user, "Bonjour la monde!", DateTime.MinValue.AddYears(1)),
new Post(user, "Sekai, konnichiwa!", DateTime.MinValue.AddYears(2))
};
user.Publish(posts[0]);
user.Publish(posts[1]);
user.Publish(posts[2]);
var spy = new OutputSpy();
var command = new PrintPosts(new PostFormatterDummy(p => p.Message), spy);
command.Execute(user);
Assert.Equal(
new[] { "Sekai, konnichiwa!", "Bonjour la monde!", "Hello, world!" },
spy.CalledWith);
}
示例4: CallsThePrintFormatter
public void CallsThePrintFormatter()
{
var user = new User("Alice");
var post = new Post(user, "Hello!", DateTime.Now);
user.Publish(post);
var spy = new PostFormatterSpy();
var oSpy = new OutputSpy();
var command = new PrintPosts(spy, oSpy);
command.Execute(user);
Assert.Equal(new[] { post }, spy.CalledWith);
}
示例5: OutputsFormattedStrings
public void OutputsFormattedStrings()
{
var alice = new User("Alice");
var bob = new User("Bob");
var post = new Post(bob, "Hello, World!", DateTime.Now);
alice.Follow(bob);
bob.Publish(post);
var outputSpy = new OutputSpy();
var postFormatter = new PostFormatterDummy("Hello!");
var command = new PrintWall(postFormatter, outputSpy);
command.Execute(alice);
Assert.Equal(new[] { "Hello!" }, outputSpy.CalledWith);
}