Exemple #1
0
 public void WhenChangeTheTextAndAddPictureThePostThroughTheAPIRequest()
 {
     Log.Step("Edit the post through the API request - change the text and add (load) any picture.");
     ScenarioContext.Current["messageEditPost"] = RandomUtils.RandomString(LenghtMessage);
     photoInfo = VkApiUtils.AddPhotoWithMessage(_userId, ScenarioContext.Current.Get <String>("idPost"),
                                                VkMethodItems.PHOTOS_SAVE_WALL_PHOTO.GetStringMapping(), _token, _pathToFolderResources + _photoOriginalName, ScenarioContext.Current.Get <String>("messageEditPost"));
 }
Exemple #2
0
 public AttachmentProcessor(VkApi vkApi, VkApiUtils vkApiUtils, FilesystemTools filesystemTools, DownloadQueueProvider downloadQueueProvider, IServiceProvider serviceProvider)
 {
     ServiceProvider            = serviceProvider;
     this.vkApi                 = vkApi;
     this.vkApiUtils            = vkApiUtils;
     this.filesystemTools       = filesystemTools;
     this.downloadQueueProvider = downloadQueueProvider;
 }
Exemple #3
0
        public void WhenReatePostWithRandomlyGeneratedTextOnTheWallAndGetTheRecordIdFromTheResponse()
        {
            Log.Step("Using the API request, create an post with randomly generated text on the wall and get the record id from the response");
            var messagePost = RandomUtils.RandomString(LenghtMessage);

            ScenarioContext.Current["messagePost"] = messagePost;
            ScenarioContext.Current["idPost"]      = VkApiUtils.CreateWallPost(_userId, VkMethodItems.WALL_POST.GetStringMapping(), _token, messagePost);
        }
Exemple #4
0
        public void WhenUsingTheAPIRequestAddACommentToThePostWithRandomText()
        {
            Log.Step("Using the API request, add a comment to the post with random text");
            var messageComment = RandomUtils.RandomString(LenghtMessage);

            ScenarioContext.Current["messageComment"] = messageComment;
            VkApiUtils.ExecuteMessageActionWall(_userId, ScenarioContext.Current.Get <String>("idPost"), VkMethodItems.WALL_CREATE_COMMENT.GetStringMapping(), _token, messageComment);
        }
Exemple #5
0
 public Logic(TokenMagic tokenMagic, VkApi vkApi, VkApiUtils vkApiUtils, BackgroundDownloader downloader, FilesystemTools filesystemTools, DownloadQueueProvider queueProvider, WallHandler wallHandler, AudioHandler audioHandler, PhotoHandler photoHandler, IOptionsSnapshot <Settings> settings)
 {
     this.settings        = settings.Value;
     this.tokenMagic      = tokenMagic;
     this.vkApi           = vkApi;
     this.vkApiUtils      = vkApiUtils;
     this.downloader      = downloader;
     this.filesystemTools = filesystemTools;
     this.queueProvider   = queueProvider;
     this.wallHandler     = wallHandler;
     this.audioHandler    = audioHandler;
     this.photoHandler    = photoHandler;
 }
Exemple #6
0
        /* Кнопки */
        /* Формирует бд */
        private void ButtonCreateDB(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(this.ToString() + ": Сформировать БД");
            if (!auth)
            {
                auth = VkApiUtils.Auth();
            }

            if (auth)
            {
                new CreateDB().ShowDialog();
            }
            else
            {
                new Login().ShowDialog();
            }
        }
 private void ButtonAuth(object sender, RoutedEventArgs e)
 {
     Console.WriteLine(this.ToString() + ": Авторизация");
     if (VkApiUtils.Auth(Token.Text))
     {
         Console.WriteLine(this.ToString() + ": Успешная авторизация");
         Result.Content    = "Успешно!";
         Result.Foreground = new SolidColorBrush(Colors.Green);
         this.Close();
         new CreateDB().Show();
     }
     else
     {
         Console.WriteLine(this.ToString() + ": Ошибка авторизации");
         Result.Content    = "Ошибка!";
         Result.FontSize   = 20;
         Result.Foreground = new SolidColorBrush(Colors.Red);
     }
 }
 public WallHandler(VkApiUtils vkApiUtils, FilesystemTools filesystemTools, IHandler <Post> postHandler) : base(filesystemTools)
 {
     this.vkApiUtils  = vkApiUtils;
     this.postHandler = postHandler;
 }
Exemple #9
0
 public void ThenDeleteCreatedInfoByTest()
 {
     VkApiUtils.DeletePhotoFromSite(VkMethodItems.PHOTOS_DELETE.GetStringMapping(), _userId, photoInfo["photoId"], _token);
     mainF.DeletePhotoDownloadedFromVk(_pathToFolderResources, ScenarioContext.Current.Get <String>("downloadedFileName"));
 }
Exemple #10
0
 public void WhenDeleteTheCreatedRecord()
 {
     Log.Step("Via the API request, delete the created record");
     VkApiUtils.DeleteWallPost(_userId, ScenarioContext.Current.Get <String>("idPost"), VkMethodItems.WALL_DELETE.GetStringMapping(), _token);
 }
Exemple #11
0
 public void ThenThroughTheRequestToTheAPILikeShouldBeSentFromTheRightUser()
 {
     Log.Step("Through the request to the API, make sure that the 'Like' was sent from the right user");
     Assert.IsTrue(VkApiUtils.IsUserLikePost(_userId, ScenarioContext.Current.Get <String>("idPost"),
                                             VkMethodItems.LIKES_ISLIKED.GetStringMapping(), "post", _token), "No like from this user");
 }
 public PhotoHandler(VkApiUtils vkApiUtils, FilesystemTools filesystemTools, IHandler <AlbumWithPhoto> albumHandler) : base(filesystemTools)
 {
     this.vkApiUtils   = vkApiUtils;
     this.albumHandler = albumHandler;
 }
 public CommentsHandler(VkApiUtils vkApiUtils, FilesystemTools filesystemTools, IHandler <Comment> commentHandler) : base(filesystemTools)
 {
     this.vkApiUtils     = vkApiUtils;
     this.commentHandler = commentHandler;
 }
Exemple #14
0
        public void VkApiTesting()
        {
            Log.Step("Navigate to vk.com");
            var loginF = new LoginForm();

            Log.Step("Login");
            loginF.Login(_username, _password);

            Log.Step("Navigate to 'My Page'");
            var newsF = new NewsForm();

            newsF.ClickMyPageBtn();

            Log.Step("Using the API request, create an post with randomly generated text on the wall and get the record id from the response");
            var vkApiUtils  = new VkApiUtils();
            var messagePost = RandomUtils.RandomString(LenghtMessage);
            var idPost      = vkApiUtils.CreateWallPost(_userId, MethodEnum.WALL_POST.GetStringMapping(), _token, messagePost);

            var mainF = new MainForm();

            Log.Step("Not updating the page, check was an post on the wall with the right text from the right user");
            Assert.IsTrue(mainF.IsWallPostMessage(messagePost), "This post doesn't exist on the wall");
            Assert.IsTrue(mainF.IsWallPostUser(_userId, messagePost), "This user not sent this post to the wall");

            Log.Step("Edit the post through the API request - change the text and add (load) any picture.");
            var messageEditPost = RandomUtils.RandomString(LenghtMessage);
            var photoInfo       = vkApiUtils.AddPhotoWithMessage(_userId, idPost,
                                                                 MethodEnum.PHOTOS_SAVE_WALL_PHOTO.GetStringMapping(), _token, _pathToFolderResources + _photoOriginalName, messageEditPost);

            Log.Step(@"Without updating the page, make sure that the text of the
            message has changed and the uploaded image has been added(make sure that the pictures are the same)");
            Assert.IsTrue(mainF.IsWallPostMessage(messageEditPost), "This post didn't edited on the wall");
            var downloadedFileName = mainF.DownloadFile(_pathToFolderResources, photoInfo["photoId"]);
            var similarityImages   = mainF.ComparePhoto(_pathToFolderResources, _photoOriginalName, downloadedFileName);

            Assert.IsTrue(similarityImages < IPuzzle.LowSimilarityThreshold, "Images don't match");

            Log.Step("Using the API request, add a comment to the post with random text");
            var messageComment = RandomUtils.RandomString(LenghtMessage);

            vkApiUtils.ExecuteMessageActionWall(_userId, idPost, MethodEnum.WALL_CREATE_COMMENT.GetStringMapping(), _token, messageComment);

            Log.Step("Not updating the page, it's necessary that a comment from the right user is added to the correct post");
            Assert.IsTrue(mainF.IsCommentWallPost(messageEditPost), "This post not present on the wall");
            Assert.IsTrue(mainF.IsCommentWallPostUser(_userId, messageComment), "This user not sent this post to the wall");
            Assert.IsTrue(mainF.IsCommentWallPostMesage(messageComment), "This comment not present on the wall");

            Log.Step("Through UI, add 'Like' for the record.");
            mainF.AddLikeWallPost(messageEditPost);

            Log.Step("Through the request to the API, make sure that the 'Like' was sent from the right user");
            Assert.IsTrue(vkApiUtils.IsUserLikePost(_userId, idPost,
                                                    MethodEnum.LIKES_ISLIKED.GetStringMapping(), "post", _token), "No like from this user");

            Log.Step("Via the API request, delete the created record");
            vkApiUtils.DeleteWallPost(_userId, idPost, MethodEnum.WALL_DELETE.GetStringMapping(), _token);

            Log.Step("Not updating the page, it's necessary to make sure that the entry is deleted");
            Assert.IsTrue(mainF.IsDeletedWallPost(), "Post wasn't deleted from the wall");
            vkApiUtils.DeletePhotoFromSite(MethodEnum.PHOTOS_DELETE.GetStringMapping(), _userId, photoInfo["photoPid"], _token);
            mainF.DeletePhotoDownloadedFromVk(_pathToFolderResources, downloadedFileName);
        }
Exemple #15
0
 public AudioHandler(VkApiUtils vkApiUtils, FilesystemTools filesystemTools, IHandler <PlaylistWithAudio> playlistHandler) : base(filesystemTools)
 {
     this.vkApiUtils      = vkApiUtils;
     this.playlistHandler = playlistHandler;
 }