本文整理汇总了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("наверное точно для демографии))"));
}
示例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>();
}
示例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>());
}