blob: 368a7675bb4a9b74193d652207f24387f3a98eba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include "apiUrl.hpp"
#include "hearthstoneApi.hpp"
#include <catch2/catch_test_macros.hpp>
#include <iostream>
#include <utility>
class TokenMock {
public:
TokenMock()
: mTokenFilePath{"resources/token_info"}, mUsername{"2b50f1123b424d5e9c21971a110fdd04"},
mPassword{"MrMkhVMNdOeqPL4Q4XVQAsRPR14J7Yq6"}, mToken{mTokenFilePath, mUsername, mPassword} {}
std::string toString() const { return mToken.toString(); }
Token &getToken() { return mToken; }
private:
const std::string mTokenFilePath;
const std::string mUsername;
const std::string mPassword;
Token mToken;
};
class HearthstoneApiMock {
public:
HearthstoneApiMock() : mHearthstoneApi(std::move(mToken.getToken())) {};
std::string makeApiRequest(const std::string &iCardsUrl) { return mHearthstoneApi.makeApiRequest(iCardsUrl); }
private:
TokenMock mToken;
const HearthstoneApi mHearthstoneApi;
};
TEST_CASE("Retrieve API Token", "[getApiToken]") {
TokenMock aToken;
const std::string kTokenContent{aToken.toString()};
std::cout << kTokenContent << '\n';
const std::string::size_type kTokenSize{kTokenContent.size()};
REQUIRE(kTokenSize >= 30);
REQUIRE(kTokenSize <= 40);
}
TEST_CASE("Retrieve number of pages", "[getPagesCount]") {
HearthstoneApiMock aHearthstoneApi;
// std::cout << aHearthstoneApi.numberOfCards() << '\n';
}
TEST_CASE("Retrieve cards", "[retrieveCards]") {
HearthstoneApiMock aHearthstoneApi;
const std::string kContentType{"cards"};
const std::string kRegion{"eu"};
ApiUrl aApiUrl(kContentType, kRegion);
aApiUrl.setLocale("fr_FR");
aApiUrl.setGameMode("constructed");
std::cout << aHearthstoneApi.makeApiRequest(aApiUrl()) << '\n';
}
|