This commit is contained in:
EonaCat 2022-02-02 19:20:57 +01:00
parent 3b3670af19
commit 527ba10c1a
4 changed files with 65 additions and 8 deletions

View File

@ -8,7 +8,12 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="EonaCat.HttpClient" Version="1.1.2" /> <Reference Include="EonaCat.Helpers">
<HintPath>..\..\EonaCatHelpers\EonaCat.Helpers\bin\Release\net5.0\EonaCat.Helpers.dll</HintPath>
</Reference>
<Reference Include="EonaCat.HttpClient">
<HintPath>..\..\EonaCatHttpClient\bin\Debug\EonaCat.HttpClient.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
</Project> </Project>

38
HttpClient/Large_Json.cs Normal file
View File

@ -0,0 +1,38 @@
namespace EonaCat.Testers.HttpClient
{
public class Actor
{
public int id { get; set; }
public string login { get; set; }
public string gravatar_id { get; set; }
public string url { get; set; }
public string avatar_url { get; set; }
}
public class Repo
{
public int id { get; set; }
public string name { get; set; }
public string url { get; set; }
}
public class Payload
{
public string @ref { get; set; }
public string ref_type { get; set; }
public string master_branch { get; set; }
public string description { get; set; }
public string pusher_type { get; set; }
}
public class Large_Json
{
public string id { get; set; }
public string type { get; set; }
public Actor actor { get; set; }
public Repo repo { get; set; }
public Payload payload { get; set; }
public bool @public { get; set; }
public DateTime created_at { get; set; }
}
}

View File

@ -1,13 +1,26 @@
 
using EonaCat.HttpClient;
namespace EonaCat.Testers.HttpClient namespace EonaCat.Testers.HttpClient
{ {
public static class HttpClientTest public static class HttpClientTest
{ {
public static void Main() private const string Large_Json_file = "https://raw.githubusercontent.com/json-iterator/test-data/master/large-file.json";
public static async Task Main()
{ {
Console.WriteLine("Test"); Console.WriteLine("Test");
var httpClient = new EonaCat.HttpClient.HttpClient("test"); var httpClient = new EonaCat.HttpClient.HttpClient(Large_Json_file);
httpClient. var getRequest = httpClient.GetRequest();
var response = await getRequest.ExecuteAsync<List<Large_Json>>().ConfigureAwait(false);
Console.WriteLine($"We got {(response.HasResult ? response.Result.Count : 0)} results - elapsed: {response.Elapsed.Value}");
Console.WriteLine("Test2");
var httpClient2 = new EonaCat.HttpClient.HttpClient("https://google.com");
var getRequest2 = httpClient2.GetRequest();
var response2 = await getRequest2.ExecuteAsHttpResponseMessageAsync().ConfigureAwait(false);
Console.WriteLine($"We got {(response2.HasResult ? await response2.Result.Content.ReadAsStringAsync() : 0)} - elapsed: {response2.Elapsed.Value}");
} }
} }
} }

View File

@ -32,13 +32,14 @@ namespace Webtester.Pages
Console.WriteLine("Testing for injections:"); Console.WriteLine("Testing for injections:");
getDone = true; getDone = true;
} }
TestInjection(test); TestInjection(test);
} }
private void TestInjection(string text) private void TestInjection(string text)
{ {
var result = SqlHelper.ExecuteQuery( var connectionString = @"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;";
new Microsoft.Data.SqlClient.SqlConnection(@"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;"), var result = SqlHelper.ExecuteQuery(connectionString,
$"SELECT * FROM Customers WHERE Country = @0", true, text); $"SELECT * FROM Customers WHERE Country = @0", true, text);
if (!result.HasResult) if (!result.HasResult)
@ -76,8 +77,8 @@ namespace Webtester.Pages
private static async void TestsqlServer() private static async void TestsqlServer()
{ {
var customerId = "AROUT"; var customerId = "AROUT";
var result = SqlHelper.ExecuteQuery( var connectionString = @"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;";
new Microsoft.Data.SqlClient.SqlConnection(@"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;"), var result = SqlHelper.ExecuteQuery(connectionString,
$"SELECT * FROM Customers WHERE CustomerID = @0 AND Country = @1" $"SELECT * FROM Customers WHERE CustomerID = @0 AND Country = @1"
, true, customerId, "UK"); , true, customerId, "UK");