当前位置: 首页>>代码示例>>C#>>正文


C# User.Publish方法代码示例

本文整理汇总了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);
        }
开发者ID:acrees,项目名称:scl,代码行数:29,代码来源:PrintWallTest.cs

示例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);
        }
开发者ID:acrees,项目名称:scl,代码行数:11,代码来源:PrintPostsTest.cs

示例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);
        }
开发者ID:acrees,项目名称:scl,代码行数:22,代码来源:PrintPostsTest.cs

示例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);
        }
开发者ID:acrees,项目名称:scl,代码行数:13,代码来源:PrintPostsTest.cs

示例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);
        }
开发者ID:acrees,项目名称:scl,代码行数:17,代码来源:PrintWallTest.cs


注:本文中的User.Publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。