Skip to content

Commit 71882e8

Browse files
authored
Update test units
* delete RotateManyExample.cs * update test units
1 parent bd40326 commit 71882e8

File tree

14 files changed

+349
-322
lines changed

14 files changed

+349
-322
lines changed
Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
1-
using System;
2-
using System.Linq;
3-
using TwoCaptcha.Captcha;
4-
5-
namespace TwoCaptcha.Examples
6-
{
7-
public class RotateExample
8-
{
9-
public void Main()
10-
{
11-
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
12-
13-
Rotate captcha = new Rotate("../../resources/rotate.jpg");
14-
15-
try
16-
{
17-
solver.Solve(captcha).Wait();
18-
Console.WriteLine("Captcha solved: " + captcha.Code);
19-
}
20-
catch (AggregateException e)
21-
{
22-
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
23-
}
24-
}
25-
}
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using TwoCaptcha.Captcha;
5+
6+
namespace TwoCaptcha.Examples
7+
{
8+
public class RotateExample
9+
{
10+
public void Main()
11+
{
12+
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
13+
14+
byte[] bytes = File.ReadAllBytes("../../resources/rotate.jpg");
15+
string base64EncodedImage = Convert.ToBase64String(bytes);
16+
Console.WriteLine("base64EncodedImage: " + base64EncodedImage);
17+
18+
19+
Rotate captcha = new Rotate();
20+
captcha.SetBase64(base64EncodedImage);
21+
22+
try
23+
{
24+
solver.Solve(captcha).Wait();
25+
Console.WriteLine("Captcha solved: " + captcha.Code);
26+
}
27+
catch (AggregateException e)
28+
{
29+
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
30+
}
31+
}
32+
}
2633
}

TwoCaptcha.Examples/RotateManyExample.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using TwoCaptcha.Captcha;
6-
7-
namespace TwoCaptcha.Examples
8-
{
9-
public class RotateOptionsExample
10-
{
11-
public void Main()
12-
{
13-
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
14-
15-
var images = new List<FileInfo>();
16-
images.Add(new FileInfo("../../resources/rotate.jpg"));
17-
images.Add(new FileInfo("../../resources/rotate_2.jpg"));
18-
images.Add(new FileInfo("../../resources/rotate_3.jpg"));
19-
20-
Rotate captcha = new Rotate();
21-
captcha.SetFiles(images);
22-
captcha.SetAngle(40);
23-
captcha.SetLang("en");
24-
captcha.SetHintImg(new FileInfo("../../resources/rotate_hint.jpg"));
25-
captcha.SetHintText("Put the images in the correct way up");
26-
27-
try
28-
{
29-
solver.Solve(captcha).Wait();
30-
Console.WriteLine("Captcha solved: " + captcha.Code);
31-
}
32-
catch (AggregateException e)
33-
{
34-
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
35-
}
36-
}
37-
}
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using TwoCaptcha.Captcha;
5+
6+
namespace TwoCaptcha.Examples
7+
{
8+
public class RotateOptionsExample
9+
{
10+
public void Main()
11+
{
12+
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
13+
14+
byte[] bytes = File.ReadAllBytes("../../resources/rotate.jpg");
15+
string base64EncodedImage = Convert.ToBase64String(bytes);
16+
17+
18+
Rotate captcha = new Rotate();
19+
captcha.SetBase64(base64EncodedImage);
20+
captcha.SetAngle(40);
21+
captcha.SetLang("en");
22+
captcha.SetHintImg(new FileInfo("../../resources/rotate.jpg"));
23+
captcha.SetHintText("Put the images in the correct way up");
24+
25+
try
26+
{
27+
solver.Solve(captcha).Wait();
28+
Console.WriteLine("Captcha solved: " + captcha.Code);
29+
}
30+
catch (AggregateException e)
31+
{
32+
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
33+
}
34+
}
35+
}
3836
}
32.5 KB
Binary file not shown.
89.7 KB
Binary file not shown.

TwoCaptcha.Tests/AmazonWafTest.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using NUnit.Framework;
4+
using TwoCaptcha.Captcha;
5+
6+
namespace TwoCaptcha.Tests
7+
{
8+
[TestFixture]
9+
public class AmazonWafTest : AbstractWrapperTestCase
10+
{
11+
[Test]
12+
public async Task TestAllOptions()
13+
{
14+
AmazonWaf captcha = new AmazonWaf();
15+
captcha.SetSiteKey("AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AF5H1K/siwSLK7RfstKtN5bAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglg");
16+
captcha.SetUrl("https://non-existent-example.execute-api.us-east-1.amazonaws.com");
17+
captcha.SetContext("test_iv");
18+
captcha.SetIV("test_context");
19+
20+
var parameters = new Dictionary<string, string>();
21+
parameters["method"] = "amazon_waf";
22+
parameters["sitekey"] = "AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AF5H1K/siwSLK7RfstKtN5bAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglg";
23+
parameters["pageurl"] = "https://non-existent-example.execute-api.us-east-1.amazonaws.com";
24+
parameters["context"] = "test_iv";
25+
parameters["iv"] = "test_context";
26+
27+
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
28+
}
29+
}
30+
}

TwoCaptcha.Tests/AudioTest.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Threading.Tasks;
5+
using NUnit.Framework;
6+
using TwoCaptcha.Captcha;
7+
8+
namespace TwoCaptcha.Tests
9+
{
10+
[TestFixture]
11+
public class AudioTest : AbstractWrapperTestCase
12+
{
13+
14+
[Test]
15+
public async Task TestAllParameters()
16+
{
17+
byte[] bytes = File.ReadAllBytes("../../../resources/audio-en.mp3");
18+
string base64EncodedImage = Convert.ToBase64String(bytes);
19+
20+
21+
AudioCaptcha captcha = new AudioCaptcha();
22+
captcha.SetBase64(base64EncodedImage);
23+
captcha.SetLang("en");
24+
25+
26+
var parameters = new Dictionary<string, string>();
27+
parameters["method"] = "audio";
28+
parameters["lang"] = "en";
29+
parameters["body"] = base64EncodedImage;
30+
31+
32+
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
33+
}
34+
35+
}
36+
}

TwoCaptcha.Tests/GeeTestV4Test.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using NUnit.Framework;
4+
using TwoCaptcha.Captcha;
5+
6+
namespace TwoCaptcha.Tests
7+
{
8+
[TestFixture]
9+
public class GeeTestV4Test : AbstractWrapperTestCase
10+
{
11+
[Test]
12+
public async Task TestAllOptions()
13+
{
14+
GeeTestV4 captcha = new GeeTestV4();
15+
captcha.SetCaptchaId("72bf15796d0b69c43867452fea615052");
16+
captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
17+
captcha.SetUrl("https://mysite.com/captcha.html");
18+
19+
var parameters = new Dictionary<string, string>();
20+
parameters["method"] = "geetest_v4";
21+
parameters["captcha_id"] = "72bf15796d0b69c43867452fea615052";
22+
parameters["challenge"] = "12345678abc90123d45678ef90123a456b";
23+
parameters["pageurl"] = "https://mysite.com/captcha.html";
24+
25+
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
26+
}
27+
}
28+
}

TwoCaptcha.Tests/HCaptchaTest.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
using System.Collections.Generic;
2-
using System.Threading.Tasks;
3-
using NUnit.Framework;
4-
using TwoCaptcha.Captcha;
5-
6-
namespace TwoCaptcha.Tests
7-
{
8-
[TestFixture]
9-
public class HCaptchaTest : AbstractWrapperTestCase
10-
{
11-
[Test]
12-
public async Task TestAllOptions()
13-
{
14-
HCaptcha captcha = new HCaptcha();
15-
captcha.SetSiteKey("f1ab2cdefa3456789012345b6c78d90e");
16-
captcha.SetUrl("https://www.site.com/page/");
17-
18-
var parameters = new Dictionary<string, string>();
19-
parameters["method"] = "hcaptcha";
20-
parameters["sitekey"] = "f1ab2cdefa3456789012345b6c78d90e";
21-
parameters["pageurl"] = "https://www.site.com/page/";
22-
23-
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
24-
}
25-
}
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using NUnit.Framework;
4+
using TwoCaptcha.Captcha;
5+
6+
namespace TwoCaptcha.Tests
7+
{
8+
[TestFixture]
9+
public class HCaptchaTest : AbstractWrapperTestCase
10+
{
11+
[Test]
12+
public async Task TestAllOptions()
13+
{
14+
HCaptcha captcha = new HCaptcha();
15+
captcha.SetSiteKey("f1ab2cdefa3456789012345b6c78d90e");
16+
captcha.SetUrl("https://www.site.com/page/");
17+
18+
var parameters = new Dictionary<string, string>();
19+
parameters["method"] = "hcaptcha";
20+
parameters["sitekey"] = "f1ab2cdefa3456789012345b6c78d90e";
21+
parameters["pageurl"] = "https://www.site.com/page/";
22+
23+
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
24+
}
25+
}
2626
}

TwoCaptcha.Tests/LeminTest.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using NUnit.Framework;
4+
using TwoCaptcha.Captcha;
5+
6+
namespace TwoCaptcha.Tests
7+
{
8+
[TestFixture]
9+
public class LeminTest : AbstractWrapperTestCase
10+
{
11+
[Test]
12+
public async Task TestAllOptions()
13+
{
14+
Lemin captcha = new Lemin();
15+
captcha.SetCaptchaId("CROPPED_d3d4d56_73ca4008925b4f83a8bed59c2dd0df6d");
16+
captcha.SetApiServer("api.leminnow.com");
17+
captcha.SetUrl("http://sat2.aksigorta.com.tr");
18+
19+
var parameters = new Dictionary<string, string>();
20+
parameters["method"] = "lemin";
21+
parameters["captcha_id"] = "CROPPED_d3d4d56_73ca4008925b4f83a8bed59c2dd0df6d";
22+
parameters["api_server"] = "api.leminnow.com";
23+
parameters["pageurl"] = "http://sat2.aksigorta.com.tr";
24+
25+
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)