Пример #1
0
        public void VkApiProvider_VkApi_Environment_References()
        {
            var environmentA = VkApiProvider.Get()
                               .GetEnvironment();

            var environmentB = VkApiProvider.Get()
                               .GetEnvironment();

            Assert.NotEqual(environmentA, environmentB);

            VkApiProvider.Get()
            .Authorize(new AuthorizationData("access_token"));

            var accessToken = VkApiProvider.Get()
                              .GetEnvironment()
                              .AccessToken;

            Assert.Equal("access_token", accessToken);

            VkApiProvider.Get()
            .GetEnvironment()
            .AccessToken = "new_access_token";

            accessToken = VkApiProvider.Get()
                          .GetEnvironment()
                          .AccessToken;

            Assert.Equal("access_token", accessToken);
        }
Пример #2
0
 public PullerStrategies(VkApiProvider vkApi, JsApiProvider jsApi)
 {
     _actualContentPullerStrategy           = new VkActualContentPullerStrategy(vkApi.WallGet);
     _actualTimePeriodContentPullerStrategy = new VkActualTimePeriodContentPullerStrategy(vkApi.WallGet);
     _postponedContentPullerStrategy        = new VkPostponedContentPullerStrategy(vkApi.WallGet);
     _historyContentPullerStrategy          = new HistoryContentPullerStrategy(jsApi.GetPosts);
 }
Пример #3
0
        public static void Ban()
        {
            var response = VkApiProvider.Get()
                           .GetAccount()
                           .Ban(new ParametersBan {
                OwnerId = 95167253
            });

            Console.WriteLine(response.Result);
        }
Пример #4
0
        private static void Main()
        {
            VkApiProvider.Get()
            .Authorize(new AuthorizationData(AccessToken));

            // Account();
            // Database();

            Console.ReadKey();
        }
Пример #5
0
        public static void GetChairs()
        {
            var response = VkApiProvider.Get()
                           .GetDatabase()
                           .GetChairs(new ParametersGetChairs {
                FacultyId = 15
            });

            Console.WriteLine(Serializer.Serialize(response.Items));
        }
Пример #6
0
        public AuthBarViewModel(IEventAggregator eventAggregator, VkApiProvider vkApi)
        {
            _eventAggregator = eventAggregator;
            _vkApi           = vkApi;

            AuthorizeCommand = new DelegateCommand(authorizeCommandExecute, () => !IsBusy).ObservesProperty(() => IsBusy);
            LogOutCommand    = new DelegateCommand(logOutCommandExecute, () => !IsBusy).ObservesProperty(() => IsBusy);

            _eventAggregator.GetEvent <AuthBarEvents.AuthorizeIfAlreadyLoggined>().Subscribe(authorizeIfAlreadyLoggined);
            _eventAggregator.GetEvent <VkAuthorizationEvents.AcquiredTheToken>().Subscribe(onTokenAcquired);
        }
Пример #7
0
        public void VkApiProvider_References_Test()
        {
            var account = VkApiProvider
                          .GetVkApi()
                          .GetAccount();

            Assert.Same(account, VkApiProvider.GetAccount());

            account = VkApiProvider
                      .GetAccount();

            Assert.Same(account, VkApiProvider.GetAccount());
        }
Пример #8
0
        private static void Main()
        {
            // На данный момент авторизация производится по уже полученному ключу доступа.
            // Полученный ключ доступа необходимо вставить в файл "access_token.json".
            VkApiProvider.Authorize(new AuthorizationData(Data.AccessToken));

            Console.WriteLine(
                VkApiProvider
                .GetEnvironment()
                .AccessToken
                );

            Console.ReadKey();
        }
        public void Setup()
        {
            var token   = new AccessToken();
            var handler = new FakeResponseHandlerByHost();

            handler.AddFakeResponse(new Uri($"https://api.vk.com/method/wall.get?"),
                                    new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(Resources.FakeWallGetResponse)
            });

            var vkApi = new vk.Models.VkApi.VkApi(token, handler);

            _apiProvider = new VkApiProvider(token, vkApi);
        }
Пример #10
0
        public void EnvironmentProvider_Deauthorization_Test()
        {
            VkApiProvider
            .GetVkApi()
            .Authorize(new AuthorizationData(AccessToken));

            VkApiProvider
            .GetAccount()
            .GetInfo();

            VkApiProvider.Deauthorize();

            // Возникнет исключение, так как была произведена деавторизация (очищено окружение).
            Assert.Throws <InvalidAccessTokenException>(() => VkApiProvider.GetAccount().GetInfo());
        }
Пример #11
0
        public void VkApiProvider_VkApi_Modules_References()
        {
            var moduleA = VkApiProvider.Get()
                          .GetAccount();

            var moduleB = VkApiProvider.Get()
                          .GetAccount();

            Assert.Equal(moduleA, moduleB);

            var moduleC = VkApiProvider.Get(InstanceMode.New)
                          .GetAccount();

            Assert.NotEqual(moduleA, moduleC);
            Assert.NotEqual(moduleB, moduleC);
        }
Пример #12
0
        public void VkApiProvider_VkApi_References()
        {
            var vkA = VkApiProvider.Get();
            var vkB = VkApiProvider.Get();

            Assert.Equal(vkA, vkB);

            vkA = VkApiProvider.Get(InstanceMode.New);
            vkB = VkApiProvider.Get(InstanceMode.New);

            Assert.NotEqual(vkA, vkB);

            vkA = VkApiProvider.Get(InstanceMode.New);
            vkB = VkApiProvider.Get();

            Assert.Equal(vkA, vkB);
        }
Пример #13
0
        public void EnvironmentProvider_Mutations_Test()
        {
            var environment = VkApiProvider
                              .GetMessages()
                              .GetEnvironment();

            Assert.Equal(AccessToken, environment.AccessToken);

            VkApiProvider
            .GetMessages()
            .GetEnvironment()
            .AccessToken = "new_access_token";

            environment = VkApiProvider
                          .GetEnvironmentProvider()
                          .GetEnvironment();

            Assert.Equal(AccessToken, environment.AccessToken);
        }
Пример #14
0
 public ProvidersTests()
 {
     VkApiProvider
     .GetVkApi()
     .Authorize(new AuthorizationData(AccessToken));
 }
Пример #15
0
 public IAccount GetAccount()
 {
     return(VkApiProvider.GetAccount());
 }
 public VkPostViewModelBuilder(VkApiProvider api)
 {
     _api = api;
 }
Пример #17
0
 public HistoryController(IHistoryPublisher historyPublisher, VkApiProvider api)
 {
     _historyPublisher = historyPublisher;
     _api = api;
 }
Пример #18
0
 public VkProvider()
 {
     Api = new VkApiProvider(Config["access_token"].ToString(), Config["version"].ToString());
 }
Пример #19
0
 public IWall GetWall()
 {
     return(VkApiProvider.GetWall());
 }
Пример #20
0
 public IAds GetAds()
 {
     return(VkApiProvider.GetAds());
 }
Пример #21
0
        public UploaderViewModel(IEventAggregator eventAggregator, VkUploader uploader, UploadSettings uploadSettings,
                                 VkApiProvider vkApi, PullersController pullersController)
        {
            _eventAggregator   = eventAggregator;
            _uploader          = uploader;
            _uploadSettings    = uploadSettings;
            _vkApi             = vkApi;
            _pullersController = pullersController;
            MissingDates       = new List <int>();

            _pullersController.Postponed.PullInvoked       += onPostponedPullInvoked;
            _pullersController.Postponed.PullCompleted     += onPostponedPullCompleted;
            _pullersController.Postponed.WallHolderChanged += onPostponedWallHolderChanged;

            _shrinkAfterPublish = _uploadSettings.CloseUploadWindowAfterPublish;
            _signedPost         = _uploadSettings.SignedPosting;
            _postFromGroup      = _uploadSettings.PostFromGroup;

            Attachments = new ObservableCollection <AttachmentItem>();

            _cts = new CancellationTokenSource();

            CancelCommand = new DelegateCommand(() => {
                _cts.Cancel();
            }, () => IsShowing)
                            .ObservesProperty(() => IsShowing);

            ShowHideCommand = new DelegateCommand(() => {
                IsShowing = !IsShowing;
            });

            PublishCommand = DelegateCommand.FromAsyncHandler(publishExecute,
                                                              () => IsEnabled && IsShowing && !IsBusy && (!string.IsNullOrWhiteSpace(Message) || Attachments.Any()))
                             .ObservesProperty(() => IsShowing)
                             .ObservesProperty(() => IsBusy)
                             .ObservesProperty(() => Message)
                             .ObservesProperty(() => Attachments)
                             .ObservesProperty(() => IsEnabled);

            BrowseCommand = DelegateCommand.FromAsyncHandler(browseExecute, () => IsShowing)
                            .ObservesProperty(() => IsShowing);

            MovePreviousCommand = new DelegateCommand(moveToPreviousMissing);
            MoveNextCommand     = new DelegateCommand(moveToNextMissing);

            //_eventAggregator.GetEvent<MainBottomEvents.Refresh>().Subscribe(async () => {
            //   if (IsBusy || !IsEnabled) return;
            //   IsBusy = true;
            //   ProgressString = "Pull...";
            //   try {
            //      await _wallContainer.PullWithScheduleHightlightAsync(new MissingPostFilter(), new Schedule());
            //   }
            //   finally {
            //      IsBusy = false;
            //      ProgressString = "";
            //   }
            //});

            _eventAggregator.GetEvent <UploaderEvents.SetVisibility>().Subscribe(onSetVisibility);
            _eventAggregator.GetEvent <UploaderEvents.Configure>().Subscribe(onConfigure);
        }
Пример #22
0
 public HistoryPostViewModelBuilder(VkApiProvider api)
 {
     _api = api;
 }
Пример #23
0
 public IMessages GetMessages()
 {
     return(VkApiProvider.GetMessages());
 }