添加测试文件

pull/2/head
Mr Li 5 years ago
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"
}
}

@ -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

Loading…
Cancel
Save