Методы для работы с сообщениями.
Example #1
0
		public void GetDialogs_AccessTokenInvalid_ThrowAccessTokenInvalidException()
		{
			var cat = new MessagesCategory(new VkApi());
			int totalCount;
			int unreadCount;
			This.Action(() => cat.GetDialogs(out totalCount, out unreadCount, 0, 201)).Throws<AccessTokenInvalidException>();
		}
Example #2
0
		public void GetDialogs_AccessTokenInvalid_ThrowAccessTokenInvalidException()
		{
			var cat = new MessagesCategory(new VkApi());
			int totalCount;
			int unreadCount;
			Assert.That(() => cat.GetDialogs(out totalCount, out unreadCount, 0, 201), Throws.InstanceOf<AccessTokenInvalidException>());
		}
Example #3
0
 public void MarkAsRead_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.MarkAsRead(1)).Throws<AccessTokenInvalidException>();
 }
Example #4
0
 public void Get_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     int totalCount;
     This.Action(() => cat.Get(MessageType.Received, out totalCount)).Throws<AccessTokenInvalidException>();
 }
Example #5
0
 public void GetLastActivity_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.GetLastActivity(1)).Throws<AccessTokenInvalidException>();
 }
Example #6
0
 public void GetHistory_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     int totalCount;
     This.Action(() => cat.GetHistory(out totalCount, false, 1)).Throws<AccessTokenInvalidException>();
 }
Example #7
0
 public void GetById_Multiple_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     int totalCount;
     This.Action(() => cat.GetById(out totalCount, new ulong[] { 1, 3, 5 })).Throws<AccessTokenInvalidException>();
 }
Example #8
0
 public void Delete_Multiple_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.Delete(new ulong[] { 1 })).Throws<AccessTokenInvalidException>();
 }
Example #9
0
 public void RemoveChatUser_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     cat.RemoveChatUser(2, 2);
 }
Example #10
0
 public void MarkAsRead_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     cat.MarkAsRead(1);
 }
Example #11
0
        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("наверное точно для демографии))"));
        }
Example #12
0
 public void CreateChat_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     cat.CreateChat(new long[] { 1, 2 }, "hi, friends");
 }
Example #13
0
 public void GetLastActivity_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     cat.GetLastActivity(1);
 }
Example #14
0
 public void GetHistory_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     int totalCount;
     cat.GetHistory(1, false, out totalCount);
 }
Example #15
0
 public void GetDialogs_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     int totalCount;
     cat.GetDialogs(1, out totalCount);
 }
Example #16
0
 public void Search_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     int totalCount;
     This.Action(() => cat.Search("привет", out totalCount)).Throws<AccessTokenInvalidException>();
 }
Example #17
0
 public void Send_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.Send(new MessageSendParams {UserId = 1, Message = "Привет, Паша!" })).Throws<AccessTokenInvalidException>();
 }
Example #18
0
 public void Restore_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     cat.Restore(1);
 }
Example #19
0
 public void EditChat_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.EditChat(2, "new title")).Throws<AccessTokenInvalidException>();
 }
Example #20
0
 public void SearchDialogs_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     cat.SearchDialogs("hello");
 }
Example #21
0
 public void GetChatUsers_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.GetChatUsers(2)).Throws<AccessTokenInvalidException>();
 }
Example #22
0
 public void DeleteDialog_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     cat.DeleteDialog(111, false);
 }
Example #23
0
 public void CreateChat_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.CreateChat(new ulong[] { 1, 2 }, "hi, friends")).Throws<AccessTokenInvalidException>();
 }
Example #24
0
File: VkApi.cs Project: vknet/vk
        /// <summary>
        /// Инициализирует новый экземпляр класса <see cref="VkApi"/>.
        /// </summary>
        public VkApi(ICaptchaSolver captchaSolver = null)
        {
            Browser = new Browser();

            Users = new UsersCategory(this);
            Friends = new FriendsCategory(this);
            Status = new StatusCategory(this);
            Messages = new MessagesCategory(this);
            Groups = new GroupsCategory(this);
            Audio = new AudioCategory(this);
            Wall = new WallCategory(this);
            Board = new BoardCategory(this);
            Database = new DatabaseCategory(this);
            Utils = new UtilsCategory(this);
            Fave = new FaveCategory(this);
            Video = new VideoCategory(this);
            Account = new AccountCategory(this);
            Photo = new PhotoCategory(this);
            Docs = new DocsCategory(this);
            Likes = new LikesCategory(this);
            Pages = new PagesCategory(this);
            Gifts = new GiftsCategory(this);
            Apps = new AppsCategory(this);
            NewsFeed = new NewsFeedCategory(this);
            Stats = new StatsCategory(this);
            Auth = new AuthCategory(this);
            Markets = new MarketsCategory(this);
            Execute = new ExecuteCategory(this);

            RequestsPerSecond = 3;

            MaxCaptchaRecognitionCount = 5;
            _captchaSolver = captchaSolver;
        }
Example #25
0
 public void GetLongPollServer_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.GetLongPollServer()).Throws<AccessTokenInvalidException>();
 }
Example #26
0
 public void Send_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.Send(1, false, "Привет, Паша!")).Throws<AccessTokenInvalidException>();
 }
Example #27
0
 public void DeleteDialog_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.DeleteDialog(111, false)).Throws<AccessTokenInvalidException>();
 }
Example #28
0
 public void Restore_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.Restore(1)).Throws<AccessTokenInvalidException>();
 }
Example #29
0
 public void RemoveChatUser_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.RemoveChatUser(2, 2)).Throws<AccessTokenInvalidException>();
 }
Example #30
0
 public void SearchDialogs_AccessTokenInvalid_ThrowAccessTokenInvalidException()
 {
     var cat = new MessagesCategory(new VkApi());
     This.Action(() => cat.SearchDialogs("hello")).Throws<AccessTokenInvalidException>();
 }