-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathNormalTest.cs
107 lines (88 loc) · 3.41 KB
/
NormalTest.cs
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
107
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;
namespace TwoCaptcha.Tests
{
[TestFixture]
public class NormalTest : AbstractWrapperTestCase
{
private string captchaImgPath = "../../../resources/normal.jpg";
private string hintImgPath = "../../../resources/grid_hint.jpg";
private string hintText = "Type red symbols only";
[Test]
public async Task TestSingleFile()
{
FileInfo image = new FileInfo(captchaImgPath);
Normal captcha = new Normal(captchaImgPath);
var parameters = new Dictionary<string, string>();
parameters["method"] = "post";
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);
Normal captcha = new Normal();
captcha.SetFile(image);
var parameters = new Dictionary<string, string>();
parameters["method"] = "post";
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()
{
Normal captcha = new Normal();
captcha.SetBase64("...");
var parameters = new Dictionary<string, string>();
parameters["method"] = "base64";
parameters["body"] = "...";
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);
Normal captcha = new Normal();
captcha.SetFile(image);
captcha.SetNumeric(4);
captcha.SetMinLen(5);
captcha.SetMaxLen(20);
captcha.SetPhrase(true);
captcha.SetCaseSensitive(true);
captcha.SetCalc(false);
captcha.SetLang("en");
captcha.SetHintImg(hintImg);
captcha.SetHintText(hintText);
var parameters = new Dictionary<string, string>();
parameters["method"] = "post";
parameters["numeric"] = "4";
parameters["min_len"] = "5";
parameters["max_len"] = "20";
parameters["phrase"] = "1";
parameters["regsense"] = "1";
parameters["calc"] = "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);
}
}
}