添加测试文件
parent
b5a9e05b7d
commit
d237b1da57
@ -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<StatusReportBgTask>();
|
||||
await statusReportBgTask.StartAsync();
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ocelot.Provider.Nacos\Ocelot.Provider.Nacos.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.json" Condition="'$(ExcludeConfigFilesFromBuildOutput)'=='true'">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"nacos": {
|
||||
"ServerAddresses": [ "http://localhost:8848" ],
|
||||
"DefaultTimeOut": 15000,
|
||||
"Namespace": "",
|
||||
"ListenInterval": 1000,
|
||||
"ServiceName": "apigateway.test"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue