Методы для работы с информацией о пользователях.
Exemplo n.º 1
0
		public void Get_EmptyAccessToken_ThrowAccessTokenInvalidException()
        {
			// Метод Get не требует AccessToken
            var users = new UsersCategory(new VkApi() { AccessToken = null });

            This.Action(() => users.Get(1)).Throws<AccessTokenInvalidException>();
        }
Exemplo n.º 2
0
        public void Get_NotAccessToInternet_ThrowVkApiException()
        {   
            var mockBrowser = new Mock<IBrowser>();
            mockBrowser.Setup(f => f.GetJson(It.IsAny<string>())).Throws(new VkApiException("The remote name could not be resolved: 'api.vk.com'"));

            var users = new UsersCategory(new VkApi {AccessToken = "asgsstsfast", Browser = mockBrowser.Object});

            var ex = This.Action(() => users.Get(1)).Throws<VkApiException>(); 
            ex.Message.ShouldEqual("The remote name could not be resolved: 'api.vk.com'");
        }
Exemplo n.º 3
0
        public void Get_EmptyAccessToken_ThrowAccessTokenInvalidException()
        {
            var users = new UsersCategory(new VkApi());

            This.Action(() => users.Get(1)).Throws<AccessTokenInvalidException>();
        }
Exemplo n.º 4
0
 public void Get_EmptyListOfUids_ThrowArgumentNullException()
 {
     var users = new UsersCategory(new VkApi { AccessToken = "token" });
     IEnumerable<long> userIds = null;
     This.Action(() => users.Get(userIds)).Throws<ArgumentNullException>();
 }
Exemplo n.º 5
0
Arquivo: VkApi.cs Projeto: 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;
        }
Exemplo n.º 6
0
 public void IsAppUser_EmptyAccessToken_ThrowAccessTokenInvalidException()
 {
     var users = new UsersCategory(new VkApi());
     users.IsAppUser(1);
 }
Exemplo n.º 7
0
 public void Get_Multiple_EmptyAccessToken_ThrowAccessTokenInvalidException()
 {
     var users = new UsersCategory(new VkApi());
     users.Get(new long[] {1, 2});
 }
Exemplo n.º 8
0
        public void Get_Multiple_EmptyAccessToken_ThrowAccessTokenInvalidException()
        {
            var users = new UsersCategory(new VkApi());
			Assert.That(() => users.Get(new long[] { 1, 2 }), Throws.InstanceOf<AccessTokenInvalidException>());
		}