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


C# MessagesCategory.Get方法代码示例

本文整理汇总了C#中VkNet.Categories.MessagesCategory.Get方法的典型用法代码示例。如果您正苦于以下问题:C# MessagesCategory.Get方法的具体用法?C# MessagesCategory.Get怎么用?C# MessagesCategory.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VkNet.Categories.MessagesCategory的用法示例。


在下文中一共展示了MessagesCategory.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Get_NormalCaseAllFields_Messages

        public void Get_NormalCaseAllFields_Messages()
        {
            url = "https://api.vk.com/method/messages.get?out=0&offset=5&count=3&filters=8&preview_length=100&time_offset=41712634&access_token=token";
            json =
                @"{
                    'response': [
                      2217,
                      {
                        'id': 4434,
                        'date': 1342169928,
                        'out': 0,
                        'user_id': 245242,
                        'read_state': 0,
                        'title': ' ... ',
                        'body': 'собирлись больше'
                      },
                      {
                        'id': 4433,
                        'date': 1342169920,
                        'out': 0,
                        'user_id': 245242,
                        'read_state': 0,
                        'title': ' ... ',
                        'body': 'не особо'
                      },
                      {
                        'id': 4431,
                        'date': 1342169360,
                        'out': 0,
                        'user_id': 245242,
                        'read_state': 1,
                        'title': ' ... ',
                        'body': 'наверное точно для демографии))'
                      }
                    ]
                  }";

            var browser = new Mock<IBrowser>();
            browser.Setup(m => m.GetJson(It.IsAny<string>())).Returns(json);
            var cat = new MessagesCategory(new VkApi {AccessToken = "token", Browser = browser.Object});

            int totalCount;
            var msgs = cat.Get(MessageType.Received, out totalCount, 3, 5, MessagesFilter.Important, 100, new DateTime(2012, 7, 1)).ToList();

            Assert.That(totalCount, Is.EqualTo(2217));
            Assert.That(msgs.Count, Is.EqualTo(3));

            Assert.That(msgs[0].Id, Is.EqualTo(4434));
            Assert.That(msgs[0].Date, Is.EqualTo(new DateTime(2012, 7, 13, 12, 58, 48)));
            Assert.That(msgs[0].Type, Is.EqualTo(MessageType.Received));
            Assert.That(msgs[0].UserId, Is.EqualTo(245242));
            Assert.That(msgs[0].ReadState, Is.EqualTo(MessageReadState.Unreaded));
            Assert.That(msgs[0].Title, Is.EqualTo(" ... "));
            Assert.That(msgs[0].Body, Is.EqualTo("собирлись больше"));

            Assert.That(msgs[1].Id, Is.EqualTo(4433));
            Assert.That(msgs[1].Date, Is.EqualTo(new DateTime(2012, 7, 13, 12, 58, 40)));
            Assert.That(msgs[1].Type, Is.EqualTo(MessageType.Received));
            Assert.That(msgs[1].UserId, Is.EqualTo(245242));
            Assert.That(msgs[1].ReadState, Is.EqualTo(MessageReadState.Unreaded));
            Assert.That(msgs[1].Title, Is.EqualTo(" ... "));
            Assert.That(msgs[1].Body, Is.EqualTo("не особо"));

            Assert.That(msgs[2].Id, Is.EqualTo(4431));
            Assert.That(msgs[2].Date, Is.EqualTo(new DateTime(2012, 7, 13, 12, 49, 20)));
            Assert.That(msgs[2].Type, Is.EqualTo(MessageType.Received));
            Assert.That(msgs[2].UserId, Is.EqualTo(245242));
            Assert.That(msgs[2].ReadState, Is.EqualTo(MessageReadState.Readed));
            Assert.That(msgs[2].Title, Is.EqualTo(" ... "));
            Assert.That(msgs[2].Body, Is.EqualTo("наверное точно для демографии))"));
        }
开发者ID:justloot,项目名称:vk,代码行数:71,代码来源:MessagesCategoryTest.cs

示例2: Get_AccessTokenInvalid_ThrowAccessTokenInvalidException

 public void Get_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     int totalCount;
     This.Action(() => cat.Get(MessageType.Received, out totalCount)).Throws<AccessTokenInvalidException>();
 }
开发者ID:Olegasdf,项目名称:vk,代码行数:6,代码来源:MessagesCategoryTest.cs

示例3: Get_AccessTokenInvalid_ThrowAccessTokenInvalidException

 public void Get_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     int totalCount;
     Assert.That(() => cat.Get(MessageType.Received, out totalCount), Throws.InstanceOf<AccessTokenInvalidException>());
 }
开发者ID:VladimirTyrin,项目名称:vk,代码行数:6,代码来源:MessagesCategoryTest.cs


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