diff --git a/HttpClient/HttpClient.csproj b/HttpClient/HttpClient.csproj index ebab9e9..bde874a 100644 --- a/HttpClient/HttpClient.csproj +++ b/HttpClient/HttpClient.csproj @@ -8,7 +8,12 @@ - + + ..\..\EonaCatHelpers\EonaCat.Helpers\bin\Release\net5.0\EonaCat.Helpers.dll + + + ..\..\EonaCatHttpClient\bin\Debug\EonaCat.HttpClient.dll + diff --git a/HttpClient/Large_Json.cs b/HttpClient/Large_Json.cs new file mode 100644 index 0000000..76d8bd4 --- /dev/null +++ b/HttpClient/Large_Json.cs @@ -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; } + } +} \ No newline at end of file diff --git a/HttpClient/Program.cs b/HttpClient/Program.cs index 40d81ec..ff357c5 100644 --- a/HttpClient/Program.cs +++ b/HttpClient/Program.cs @@ -1,13 +1,26 @@  +using EonaCat.HttpClient; + namespace EonaCat.Testers.HttpClient { 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"); - var httpClient = new EonaCat.HttpClient.HttpClient("test"); - httpClient. + var httpClient = new EonaCat.HttpClient.HttpClient(Large_Json_file); + var getRequest = httpClient.GetRequest(); + var response = await getRequest.ExecuteAsync>().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}"); + } } } \ No newline at end of file diff --git a/SqlTester/Webtester/Pages/Index.cshtml.cs b/SqlTester/Webtester/Pages/Index.cshtml.cs index b483748..1b131b3 100644 --- a/SqlTester/Webtester/Pages/Index.cshtml.cs +++ b/SqlTester/Webtester/Pages/Index.cshtml.cs @@ -32,13 +32,14 @@ namespace Webtester.Pages Console.WriteLine("Testing for injections:"); getDone = true; } + TestInjection(test); } private void TestInjection(string text) { - var result = SqlHelper.ExecuteQuery( - new Microsoft.Data.SqlClient.SqlConnection(@"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;"), + var connectionString = @"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;"; + var result = SqlHelper.ExecuteQuery(connectionString, $"SELECT * FROM Customers WHERE Country = @0", true, text); if (!result.HasResult) @@ -76,8 +77,8 @@ namespace Webtester.Pages private static async void TestsqlServer() { var customerId = "AROUT"; - var result = SqlHelper.ExecuteQuery( - new Microsoft.Data.SqlClient.SqlConnection(@"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;"), + var connectionString = @"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" , true, customerId, "UK");