From 40150215f2493c60778a43dfd0afd00d1e8e4e70 Mon Sep 17 00:00:00 2001 From: EonaCat Date: Wed, 21 Sep 2022 16:53:02 +0200 Subject: [PATCH] Updated --- HttpClient/HttpClient.csproj | 4 ++-- HttpClient/Program.cs | 18 +++++++++++++++++- Mocktester/MockTester.csproj | 28 ++++++++++++++++++++++++++++ Mocktester/MockTester.sln | 31 +++++++++++++++++++++++++++++++ Mocktester/Program.cs | 26 ++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 Mocktester/MockTester.csproj create mode 100644 Mocktester/MockTester.sln create mode 100644 Mocktester/Program.cs diff --git a/HttpClient/HttpClient.csproj b/HttpClient/HttpClient.csproj index bde874a..be7a018 100644 --- a/HttpClient/HttpClient.csproj +++ b/HttpClient/HttpClient.csproj @@ -9,10 +9,10 @@ - ..\..\EonaCatHelpers\EonaCat.Helpers\bin\Release\net5.0\EonaCat.Helpers.dll + ..\..\EonaCat.Helpers\EonaCat.Helpers\bin\Release\net6.0\EonaCat.Helpers.dll - ..\..\EonaCatHttpClient\bin\Debug\EonaCat.HttpClient.dll + ..\..\EonaCat.HttpClient\EonaCat.HttpClient\bin\Debug\EonaCat.HttpClient.dll diff --git a/HttpClient/Program.cs b/HttpClient/Program.cs index ff357c5..8e288eb 100644 --- a/HttpClient/Program.cs +++ b/HttpClient/Program.cs @@ -1,5 +1,7 @@  using EonaCat.HttpClient; +using EonaCat.HttpClient.Extensions; +using System.Globalization; namespace EonaCat.Testers.HttpClient { @@ -11,16 +13,30 @@ namespace EonaCat.Testers.HttpClient { Console.WriteLine("Test"); var httpClient = new EonaCat.HttpClient.HttpClient(Large_Json_file); + httpClient.OnReadProgressChanged += HttpClient_OnReadProgressChanged; + httpClient.OnWriteProgressChanged += HttpClient_OnWriteProgressChanged; 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"); + httpClient2.OnReadProgressChanged += HttpClient_OnReadProgressChanged; + httpClient2.OnWriteProgressChanged += HttpClient_OnWriteProgressChanged; 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}"); + Console.WriteLine($"We got {(response2.HasResult ? await response2.Result.Content.ReadAsStringWithProgressAsync("test", (x) => { Console.WriteLine($"{x.PercentageAsString}%"); }) : 0)} - elapsed: {response2.Elapsed.Value}"); } + + private static void HttpClient_OnWriteProgressChanged(object? sender, ProgressArgs e) + { + Console.WriteLine($"WRITE: {e.Identifier} : {e.PercentageAsString}"); + } + + private static void HttpClient_OnReadProgressChanged(object? sender, ProgressArgs e) + { + Console.WriteLine($"READ: {e.Identifier} : {e.PercentageAsString}"); + } } } \ No newline at end of file diff --git a/Mocktester/MockTester.csproj b/Mocktester/MockTester.csproj new file mode 100644 index 0000000..4834241 --- /dev/null +++ b/Mocktester/MockTester.csproj @@ -0,0 +1,28 @@ + + + + Exe + net6.0 + disable + enable + + + + + + + + + + + + + + + + + ..\..\EonaCatHelpers\EonaCat.Helpers\bin\Release\net6.0\EonaCat.Helpers.dll + + + + diff --git a/Mocktester/MockTester.sln b/Mocktester/MockTester.sln new file mode 100644 index 0000000..b15e185 --- /dev/null +++ b/Mocktester/MockTester.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32112.339 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MockTester", "MockTester.csproj", "{D5E2E874-0FD2-4481-BE8C-517C382342AE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EonaCat.Mocking", "..\..\EonaCatMocker\EonaCat.Mocking.csproj", "{2FB81818-47C1-47CE-931D-8DF6810CED50}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D5E2E874-0FD2-4481-BE8C-517C382342AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D5E2E874-0FD2-4481-BE8C-517C382342AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D5E2E874-0FD2-4481-BE8C-517C382342AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D5E2E874-0FD2-4481-BE8C-517C382342AE}.Release|Any CPU.Build.0 = Release|Any CPU + {2FB81818-47C1-47CE-931D-8DF6810CED50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2FB81818-47C1-47CE-931D-8DF6810CED50}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2FB81818-47C1-47CE-931D-8DF6810CED50}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2FB81818-47C1-47CE-931D-8DF6810CED50}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7E7E2E90-9289-4D68-A918-A465BE4315AF} + EndGlobalSection +EndGlobal diff --git a/Mocktester/Program.cs b/Mocktester/Program.cs new file mode 100644 index 0000000..a782476 --- /dev/null +++ b/Mocktester/Program.cs @@ -0,0 +1,26 @@ + +using EonaCat.Json; +using EonaCat.Mocking; +using System; + +namespace EonaCat.Tester.Mocking +{ + public static class MockTest + { + public static void Main(string[] args) + { + var user = new MockHelper().Generate(); + Console.WriteLine(JsonHelper.ToJson(user)); + } + } + + public class User + { + public string Name { get; set; } + public int Id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public DateTime BirthDate { get; set; } + public string CompanyName { get; set; } + } +} \ No newline at end of file