From d237b1da57ecddea06ef1f064dce1ba4540074be Mon Sep 17 00:00:00 2001 From: Mr Li Date: Mon, 20 Jul 2020 16:17:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ocelot.Provider.Nacos.Test/NacosClientTest.cs | 26 ++++++++++++++++ .../Ocelot.Provider.Nacos.Test.csproj | 30 +++++++++++++++++++ Ocelot.Provider.Nacos.Test/appsettings.json | 9 ++++++ Ocelot.Provider.Nacos.sln | 7 +++++ 4 files changed, 72 insertions(+) create mode 100644 Ocelot.Provider.Nacos.Test/NacosClientTest.cs create mode 100644 Ocelot.Provider.Nacos.Test/Ocelot.Provider.Nacos.Test.csproj create mode 100644 Ocelot.Provider.Nacos.Test/appsettings.json diff --git a/Ocelot.Provider.Nacos.Test/NacosClientTest.cs b/Ocelot.Provider.Nacos.Test/NacosClientTest.cs new file mode 100644 index 0000000..b506fb8 --- /dev/null +++ b/Ocelot.Provider.Nacos.Test/NacosClientTest.cs @@ -0,0 +1,26 @@ +using System; +using System.IO; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Ocelot.Provider.Nacos.NacosClient; +using Xunit; + +namespace Ocelot.Provider.Nacos.Test +{ + public class NacosClientTest + { + [Fact] + public async void TestClient() + { + IServiceCollection services = new ServiceCollection(); + IConfigurationBuilder configurationBuilder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json"); + services.AddNacosDiscovery(configurationBuilder.Build()); + + var provider = services.BuildServiceProvider(); + StatusReportBgTask statusReportBgTask = provider.GetRequiredService(); + await statusReportBgTask.StartAsync(); + Console.ReadLine(); + } + } +} diff --git a/Ocelot.Provider.Nacos.Test/Ocelot.Provider.Nacos.Test.csproj b/Ocelot.Provider.Nacos.Test/Ocelot.Provider.Nacos.Test.csproj new file mode 100644 index 0000000..aee3909 --- /dev/null +++ b/Ocelot.Provider.Nacos.Test/Ocelot.Provider.Nacos.Test.csproj @@ -0,0 +1,30 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + + + + + + + + + + + true + PreserveNewest + Always + + + diff --git a/Ocelot.Provider.Nacos.Test/appsettings.json b/Ocelot.Provider.Nacos.Test/appsettings.json new file mode 100644 index 0000000..3e23c84 --- /dev/null +++ b/Ocelot.Provider.Nacos.Test/appsettings.json @@ -0,0 +1,9 @@ +{ + "nacos": { + "ServerAddresses": [ "http://localhost:8848" ], + "DefaultTimeOut": 15000, + "Namespace": "", + "ListenInterval": 1000, + "ServiceName": "apigateway.test" + } +} diff --git a/Ocelot.Provider.Nacos.sln b/Ocelot.Provider.Nacos.sln index f92e916..65ff3e8 100644 --- a/Ocelot.Provider.Nacos.sln +++ b/Ocelot.Provider.Nacos.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiGatewayDemo", "ApiGatewa EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductApi", "ProductApi\ProductApi.csproj", "{412DE300-5740-4EEE-9592-A48FF549BADF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ocelot.Provider.Nacos.Test", "Ocelot.Provider.Nacos.Test\Ocelot.Provider.Nacos.Test.csproj", "{4E1CC9B8-BD07-40CB-BF0C-9F0EE1FCBC79}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -31,10 +33,15 @@ Global {412DE300-5740-4EEE-9592-A48FF549BADF}.Debug|Any CPU.Build.0 = Debug|Any CPU {412DE300-5740-4EEE-9592-A48FF549BADF}.Release|Any CPU.ActiveCfg = Release|Any CPU {412DE300-5740-4EEE-9592-A48FF549BADF}.Release|Any CPU.Build.0 = Release|Any CPU + {4E1CC9B8-BD07-40CB-BF0C-9F0EE1FCBC79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E1CC9B8-BD07-40CB-BF0C-9F0EE1FCBC79}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E1CC9B8-BD07-40CB-BF0C-9F0EE1FCBC79}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E1CC9B8-BD07-40CB-BF0C-9F0EE1FCBC79}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {284367EA-EC93-4060-ABE7-3EF93A5A888C} = {B76348CD-F496-4B6E-A915-82A342AA5150} {F26F410A-1282-4756-931E-D56AC128C2FD} = {7A2BFC89-057F-4F8D-ADB7-C7D122B160EF} {412DE300-5740-4EEE-9592-A48FF549BADF} = {7A2BFC89-057F-4F8D-ADB7-C7D122B160EF} + {4E1CC9B8-BD07-40CB-BF0C-9F0EE1FCBC79} = {D7B862B3-BB35-4D94-AE3D-C78B537B5E2F} EndGlobalSection EndGlobal