-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathGridTest.cs
More file actions
106 lines (87 loc) · 3.41 KB
/
GridTest.cs
File metadata and controls
106 lines (87 loc) · 3.41 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;
namespace TwoCaptcha.Tests
{
[TestFixture]
public class GridTest : AbstractWrapperTestCase
{
private string captchaImgPath = "../../../resources/grid.jpg";
private string hintImgPath = "../../../resources/grid_hint.jpg";
private string hintText = "Select all images with an Orange";
[Test]
public async Task TestSingleFile()
{
FileInfo image = new FileInfo(captchaImgPath);
Grid captcha = new Grid(image);
var parameters = new Dictionary<string, string>();
parameters["method"] = "post";
parameters["recaptcha"] = "1";
parameters["soft_id"] = "4582";
parameters["json"] = "0";
var files = new Dictionary<string, FileInfo>();
files["file"] = image;
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
}
[Test]
public async Task TestSingleFileParameter()
{
FileInfo image = new FileInfo(captchaImgPath);
Grid captcha = new Grid();
captcha.SetFile(image);
var parameters = new Dictionary<string, string>();
parameters["method"] = "post";
parameters["recaptcha"] = "1";
parameters["soft_id"] = "4582";
parameters["json"] = "0";
var files = new Dictionary<string, FileInfo>();
files["file"] = image;
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
}
[Test]
public async Task TestBase64()
{
Grid captcha = new Grid();
captcha.SetBase64("...");
var parameters = new Dictionary<string, string>();
parameters["method"] = "base64";
parameters["body"] = "...";
parameters["recaptcha"] = "1";
parameters["soft_id"] = "4582";
parameters["json"] = "0";
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}
[Test]
public async Task TestAllParameters()
{
FileInfo image = new FileInfo(captchaImgPath);
FileInfo hintImg = new FileInfo(hintImgPath);
Grid captcha = new Grid();
captcha.SetFile(image);
captcha.SetRows(3);
captcha.SetCols(3);
captcha.SetPreviousId(0);
captcha.SetCanSkip(false);
captcha.SetLang("en");
captcha.SetHintImg(hintImg);
captcha.SetHintText(hintText);
var parameters = new Dictionary<string, string>();
parameters["method"] = "post";
parameters["recaptcha"] = "1";
parameters["recaptcharows"] = "3";
parameters["recaptchacols"] = "3";
parameters["previousID"] = "0";
parameters["can_no_answer"] = "0";
parameters["lang"] = "en";
parameters["textinstructions"] = hintText;
parameters["soft_id"] = "4582";
parameters["json"] = "0";
var files = new Dictionary<string, FileInfo>();
files["file"] = image;
files["imginstructions"] = hintImg;
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters, files);
}
}
}