예제 #1
0
        public async Task Posts_By_Category_Empty_Name(KnownChains apiName)
        {
            var request = new PostsByCategoryModel(PostType.Top, string.Empty);

            var response = await Api[apiName].GetPostsByCategory(request, CancellationToken.None);

            Assert.That(response.Exception.Message.StartsWith(nameof(LocalizationKeys.EmptyCategory)));
        }
예제 #2
0
        public async Task Posts_By_Category_Invalid_Name(KnownChains apiName)
        {
            var request = new PostsByCategoryModel(PostType.Top, "asdas&^@dsad__sa@@d sd222f_f");

            var response = await Api[apiName].GetPostsByCategory(request, CancellationToken.None);

            Assert.IsTrue(response.Exception.Message.StartsWith("<h1>Not Found</h1>"));
        }
예제 #3
0
        public async Task GetPostInfo_Invalid_Url(KnownChains apiName)
        {
            var request = new NamedInfoModel("spam/@joseph.kalu/qweqeqwqweqweqwe");

            var response = await Api[apiName].GetPostInfo(request, CancellationToken.None);

            Assert.That(response.Exception.Message.Contains("Wrong identifier."));
        }
예제 #4
0
        public async Task VotePostTest(KnownChains apiName)
        {
            var user = Users[apiName];

            // Load last created post
            var userPostsRequest = new PostsModel(PostType.New)
            {
                Login = user.Login
            };
            var userPostsResponse = await Api[apiName].GetPosts(userPostsRequest, CancellationToken.None);

            AssertResult(userPostsResponse);
            var lastPost = userPostsResponse.Result.Results.First(i => !i.Vote);

            // 4) Vote up
            var voteUpRequest  = new VoteModel(user, lastPost, VoteType.Up);
            var voteUpResponse = await Api[apiName].Vote(voteUpRequest, CancellationToken.None);

            AssertResult(voteUpResponse);
            Assert.That(voteUpResponse.Result.IsSuccess, Is.True);
            Assert.That(voteUpResponse.Result.NewTotalPayoutReward, Is.Not.Null);
            Assert.That(voteUpResponse.Result.NewTotalPayoutReward, Is.Not.Null);
            //Assert.IsTrue(lastPost.TotalPayoutReward <= voteUpResponse.Result.NewTotalPayoutReward);

            // Wait for data to be writed into blockchain
            Thread.Sleep(TimeSpan.FromSeconds(15));
            userPostsRequest.Offset = lastPost.Url;
            var userPostsResponse2 = await Api[apiName].GetPosts(userPostsRequest, CancellationToken.None);

            // Check if last post was voted
            AssertResult(userPostsResponse2);
            var post = userPostsResponse2.Result.Results.FirstOrDefault(i => i.Url.EndsWith(lastPost.Url, StringComparison.OrdinalIgnoreCase));

            Assert.IsNotNull(post);
            Console.WriteLine("The server still updates the history");
            //Assert.That(post.Vote, Is.True);

            // 3) Vote down
            var voteDownRequest  = new VoteModel(user, lastPost, VoteType.Down);
            var voteDownResponse = await Api[apiName].Vote(voteDownRequest, CancellationToken.None);

            AssertResult(voteDownResponse);
            Assert.That(voteDownResponse.Result.IsSuccess, Is.True);
            Assert.That(voteDownResponse.Result.NewTotalPayoutReward, Is.Not.Null);
            Assert.That(voteDownResponse.Result.NewTotalPayoutReward, Is.Not.Null);
            //Assert.IsTrue(lastPost.TotalPayoutReward >= voteDownResponse.Result.NewTotalPayoutReward);

            // Wait for data to be writed into blockchain
            Thread.Sleep(TimeSpan.FromSeconds(15));
            var userPostsResponse3 = await Api[apiName].GetPosts(userPostsRequest, CancellationToken.None);

            // Check if last post was voted
            AssertResult(userPostsResponse3);
            post = userPostsResponse3.Result.Results.FirstOrDefault(i => i.Url.Equals(lastPost.Url, StringComparison.OrdinalIgnoreCase));
            Assert.IsNotNull(post);
            Console.WriteLine("The server still updates the history");
            //Assert.That(post.Vote, Is.False);
        }
예제 #5
0
        public async Task LoginWithPostingKeyTest(KnownChains apiName)
        {
            var user     = Users[apiName];
            var request  = new ValidatePrivateKeyModel(user.Login, user.PostingKey, KeyRoleType.Posting);
            var response = await Api[apiName].ValidatePrivateKey(request, CancellationToken.None);

            AssertResult(response);
            Assert.That(response.IsSuccess, Is.True);
        }
예제 #6
0
        public async Task LoginWithPostingKeyTest(KnownChains apiName)
        {
            var user     = Users[apiName];
            var request  = new AuthorizedModel(user);
            var response = await Api[apiName].LoginWithPostingKey(request, CancellationToken.None);

            AssertResult(response);
            Assert.That(response.IsSuccess, Is.True);
        }
        public async Task Posts_By_Category_Not_Existing_Name(KnownChains apiName)
        {
            var request = new PostsByCategoryModel(PostType.Top, "qweqweqweqewqwqweqe");

            var response = await Api[apiName].GetPostsByCategory(request, CancellationToken.None);

            AssertResult(response);
            Assert.That(response.Result.Results, Is.Empty);
        }
        public async Task User_Search_Offset_Not_Exisiting(KnownChains apiName)
        {
            var request = new SearchWithQueryModel("aar")
            {
                Offset = "qweqweqwe"
            };
            var response = await Api[apiName].SearchUser(request, CancellationToken.None);

            Assert.IsTrue(response.Error.Message.Equals("Username used for offset was not found"));
        }
        public async Task User_Search_Empty_Query(KnownChains apiName)
        {
            // Arrange
            var request = new SearchWithQueryModel(" ");

            // Act
            var response = await Api[apiName].SearchUser(request, CancellationToken.None);

            // Assert
            Assert.IsTrue(response.Error.Message.Equals(nameof(LocalizationKeys.EmptyCategory)));
        }
        public async Task User_Search_Short_Query(KnownChains apiName)
        {
            // Arrange
            var request = new SearchWithQueryModel("fo");

            // Act
            var response = await Api[apiName].SearchUser(request, CancellationToken.None);

            // Assert
            Assert.IsTrue(response.Error.Message.Equals("Query should have at least 3 characters"));
        }
        public async Task Categories_Search_Short_Query(KnownChains apiName)
        {
            // Arrange
            var request = new SearchWithQueryModel("f");

            // Act
            var response = await Api[apiName].SearchCategories(request, CancellationToken.None);

            // Assert
            Assert.IsTrue(response.Error.Message.StartsWith(nameof(LocalizationKeys.QueryMinLength)));
        }
예제 #12
0
        public async Task Login_With_Posting_Key_Wrong_Username(KnownChains apiName)
        {
            var user = Users[apiName];

            user.Login += "x";
            var request = new AuthorizedModel(user);

            var response = await Api[apiName].LoginWithPostingKey(request, CancellationToken.None);

            Assert.IsTrue(response.Error.Message.StartsWith("13 N5boost16exception_detail10clone_implINS0_19error_info_injectorISt12out_of_rangeEEEE: unknown key"));
        }
예제 #13
0
        public async Task Login_With_Posting_Key_Wrong_PostingKey(KnownChains apiName)
        {
            var user = Users[apiName];

            user.PostingKey += "x";
            var request = new ValidatePrivateKeyModel(user.Login, user.PostingKey, KeyRoleType.Posting);

            var response = await Api[apiName].ValidatePrivateKey(request, CancellationToken.None);

            Assert.IsTrue(response.Exception.Message.StartsWith(nameof(LocalizationKeys.WrongPrivatePostingKey)));
        }
        public async Task Categories_Search_With_User(KnownChains apiName)
        {
            var request = new SearchWithQueryModel("lif");

            var response = await Api[apiName].SearchCategories(request, CancellationToken.None);

            AssertResult(response);
            Assert.That(response.Result.Results.Any());
            Assert.That(response.Result.Results, Is.Not.Empty);
            Assert.That(response.Result.Results.First().Name, Is.Not.Empty);
        }
예제 #15
0
        public async Task GetPostInfoTest(KnownChains apiName, [Values()] string url)
        {
            var request = new NamedInfoModel(url)
            {
                ShowNsfw     = true,
                ShowLowRated = true
            };
            var result = await Gateway[apiName].GetPostInfo(request, CancellationToken.None);

            Assert.IsTrue(result.IsSuccess, result.Error?.Message);
        }
        public async Task UserProfile_Invalid_Username(KnownChains apiName)
        {
            // Arrange
            var request = new UserProfileModel("qweqweqwe");

            // Act
            var response = await Api[apiName].GetUserProfile(request, CancellationToken.None);

            // Assert
            Assert.That(response.Error.Message.Equals("User not found"));
        }
예제 #17
0
        public async Task Posts_Top_Limit_Default(KnownChains apiName)
        {
            // Arrange
            var request = new PostsModel(PostType.Top);

            // Act
            var response = await Api[apiName].GetPosts(request, CancellationToken.None);

            // Assert
            AssertResult(response);
        }
예제 #18
0
        public async Task Login_With_Posting_Key_Wrong_PostingKey(KnownChains apiName)
        {
            var user = Users[apiName];

            user.PostingKey += "x";
            var request = new AuthorizedModel(user);

            var response = await Api[apiName].LoginWithPostingKey(request, CancellationToken.None);

            Assert.IsTrue(response.Error.Message.StartsWith(nameof(LocalizationKeys.WrongPrivatePostingKey)));
        }
        public async Task User_Exists_Check_Invalid_Username(KnownChains apiName)
        {
            // Arrange
            var request = new UserExistsModel("pmartynov123");

            // Act
            var response = await Api[apiName].UserExistsCheck(request, CancellationToken.None);

            // Assert
            AssertResult(response);
            Assert.False(response.Result.Exists);
        }
        public async Task UserFriends_Followers_Invalid_Username(KnownChains apiName)
        {
            // Arrange
            var user    = Users[apiName];
            var request = new UserFriendsModel(user.Login + "x", FriendsType.Followers);

            // Act
            var response = await Api[apiName].GetUserFriends(request, CancellationToken.None);

            // Assert
            Assert.IsTrue(response.Error.Message.Equals("Account does not exist"));
        }
        public async Task Categories_Search_Invalid_Query(KnownChains apiName)
        {
            // Arrange
            var request = new SearchWithQueryModel("qwerqwerqwerqwerqwerqwerqwerqwer");

            // Act
            var response = await Api[apiName].SearchCategories(request, CancellationToken.None);

            // Assert
            AssertResult(response);
            Assert.That(response.Result.Results, Is.Empty);
        }
        public async Task UserPosts_Invalid_Username(KnownChains apiName)
        {
            // Arrange
            var user    = Users[apiName];
            var request = new UserPostsModel(user.Login + "x");

            // Act
            var response = await Api[apiName].GetUserPosts(request, CancellationToken.None);

            // Assert
            Assert.That(response.Error.Message.Contains("Cannot get posts for this username"));
        }
예제 #23
0
        static BasePresenter()
        {
            CtsSync     = new object();
            CultureInfo = CultureInfo.InvariantCulture;

            Chain = AppSettings.User.Chain;

            Api = new SteepshotApiClient();

            Api.InitConnector(Chain, AppSettings.IsDev);
            LazyLoadTimer = new Timer(Callback, null, 9000, Int32.MaxValue);
        }
예제 #24
0
        public async Task UploadMediaTest(KnownChains apiName)
        {
            var user = Users[apiName];

            // 1) Create new post
            var path             = GetTestImagePath();
            var stream           = new FileStream(GetTestImagePath(), FileMode.Open);
            var uploadImageModel = new UploadMediaModel(user, stream, Path.GetExtension(path));
            var servResp         = await Api[apiName].UploadMedia(uploadImageModel, CancellationToken.None);

            AssertResult(servResp);
        }
        public async Task Posts_New(KnownChains apiName)
        {
            // Arrange
            var request = new PostsModel(PostType.New);

            // Act
            var response = await Api[apiName].GetPosts(request, CancellationToken.None);

            // Assert
            AssertResult(response);
            Assert.That(response.Result.Results, Is.Not.Empty);
        }
        public async Task GetPostVotersTest(KnownChains apiName, string url)
        {
            var request = new VotersModel(url, VotersType.All)
            {
                Limit  = 40,
                Offset = string.Empty,
            };

            var result = await Gateway[apiName].GetPostVoters(request, CancellationToken.None);

            Assert.IsTrue(result.IsSuccess, result.Error?.Message);
        }
        public async Task UserPosts_Without_User_All_Votes_False(KnownChains apiName)
        {
            // Arrange
            var user    = Users[apiName];
            var request = new UserPostsModel(user.Login);

            // Act
            var response = await Api[apiName].GetUserPosts(request, CancellationToken.None);

            // Assert
            AssertResult(response);
            Assert.That(response.Result.Results.Where(x => x.Vote).Any, Is.False);
        }
        public async Task Comments_Without_User_Check_False_Votes(KnownChains apiName)
        {
            var request = new PostsModel(PostType.Hot);
            var posts   = await Api[apiName].GetPosts(request, CancellationToken.None);


            var infoModel = new NamedInfoModel(posts.Result.Results.First(i => i.Children > 0).Url);

            var response = await Api[apiName].GetComments(infoModel, CancellationToken.None);

            AssertResult(response);
            Assert.That(response.Result.Results.Where(x => x.Vote).Any, Is.False);
        }
예제 #29
0
        public async Task GetPostVotersTest(KnownChains apiName, string url)
        {
            var count   = 40;
            var request = new VotersModel(url, VotersType.All)
            {
                Limit  = count,
                Offset = string.Empty,
            };
            var response = await Api[apiName].GetPostVoters(request, CancellationToken.None);

            AssertResult(response);
            Assert.IsTrue(response.Result.Count == count);
        }
예제 #30
0
        public async Task GetUserRecentPostsTest(KnownChains apiName)
        {
            var user    = Users[apiName];
            var request = new CensoredNamedRequestWithOffsetLimitModel
            {
                Login        = user.Login,
                ShowLowRated = true,
                ShowNsfw     = true
            };

            var result = await Gateway[apiName].GetUserRecentPosts(request, CancellationToken.None);

            Assert.IsTrue(result.IsSuccess, result.Error?.Message);
        }