diff --git a/LinkAce.sln b/LinkAce.sln index 8c2681b..ec07926 100644 --- a/LinkAce.sln +++ b/LinkAce.sln @@ -17,7 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI Workflows", "CI Workflow EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinkAce.NET", "src\LinkAce.NET\LinkAce.NET.csproj", "{6C83B6FB-E141-46BA-A446-8346BB11A7E3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "src\TestApp\TestApp.csproj", "{97052387-BAA1-40E8-A861-C412B373FBDC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestClient", "src\TestClient\TestClient.csproj", "{97052387-BAA1-40E8-A861-C412B373FBDC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/TestApp/Program.cs b/src/TestApp/Program.cs deleted file mode 100644 index 66fc253..0000000 --- a/src/TestApp/Program.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Net; -using LinkAce.NET; -using Microsoft.Extensions.Configuration; -Console.WriteLine("Hello, World!"); - -var configuration = new ConfigurationBuilder() - .AddYamlFile("settings.yml", false, true) - .Build(); - -var handler = new HttpClientHandler() -{ - Proxy = new WebProxy("localhost:8080", false) -}; -var httpClient = new HttpClient(handler); - -var linkAceConfig = configuration.GetSection("LinkAce"); -var linkAceClient = new LinkAceClient(linkAceConfig["Url"] ?? throw new InvalidOperationException(), - linkAceConfig["ApiToken"] ?? throw new InvalidOperationException(), - httpClient); -var results = linkAceClient.SearchLinksByUrl("jrgnsn.net").Result; - -var _ = () => { }; diff --git a/src/TestClient/Program.cs b/src/TestClient/Program.cs new file mode 100644 index 0000000..7cae5fa --- /dev/null +++ b/src/TestClient/Program.cs @@ -0,0 +1,46 @@ +using System.Net; +using System.Text; +using LinkAce.NET; +using LinkAce.NET.Entites; +using LinkAce.NET.Extensions; +using Microsoft.Extensions.Configuration; +Console.WriteLine("Hello, World!"); + +var configuration = new ConfigurationBuilder() + .AddYamlFile("settings.yml", false, true) + .Build(); + +var handler = new HttpClientHandler() +{ + Proxy = new WebProxy("localhost:8080", false) +}; +var httpClient = new HttpClient(handler); + +var linkAceConfig = configuration.GetSection("LinkAce"); +var linkAceClient = new LinkAceClient(linkAceConfig["Url"] ?? throw new InvalidOperationException(), + linkAceConfig["ApiToken"] ?? throw new InvalidOperationException(), + httpClient); +var results = linkAceClient.SearchLinksByUrl("jrgnsn.net").GetAwaiter().GetResult(); +var createResult = linkAceClient.CreateLink( + new Link() + { + Title = "Test Link", + Url = "https://jrgnsn.net", + Description = "A test link", + Tags = new[]{ "test" }.ToTagArray() + }).GetAwaiter().GetResult(); + +var _ = () => { }; + +string RandomString(int size) +{ + Random random = new((int)DateTime.Now.Ticks); + StringBuilder builder = new(); + char ch; + for (int i = 0; i < size; i++) + { + ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26*random.NextDouble() + 65))); + builder.Append(ch); + } + return builder.ToString(); +} \ No newline at end of file diff --git a/src/TestApp/TestApp.csproj b/src/TestClient/TestClient.csproj similarity index 94% rename from src/TestApp/TestApp.csproj rename to src/TestClient/TestClient.csproj index 84b7392..2f5f7ed 100644 --- a/src/TestApp/TestApp.csproj +++ b/src/TestClient/TestClient.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable False diff --git a/src/TestApp/settings.example.yml b/src/TestClient/settings.example.yml similarity index 100% rename from src/TestApp/settings.example.yml rename to src/TestClient/settings.example.yml