Forgot unit tests for previous commit
This commit is contained in:
Родитель
a152a23c23
Коммит
622a8a5d9f
|
@ -12,16 +12,36 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Steeltoe.CloudFoundry.Connector.Redis;
|
||||
using Steeltoe.CloudFoundry.Connector.Services;
|
||||
using Steeltoe.Common.HealthChecks;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Steeltoe.CloudFoundry.Connector.Test.Cache
|
||||
{
|
||||
public class RedisHealthContributorTest
|
||||
{
|
||||
[Fact]
|
||||
public void GetRedisContributor_ReturnsContributor()
|
||||
{
|
||||
var appsettings = new Dictionary<string, string>()
|
||||
{
|
||||
["redis:client:host"] = "localhost",
|
||||
["redis:client:port"] = "1234",
|
||||
};
|
||||
|
||||
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
|
||||
configurationBuilder.AddInMemoryCollection(appsettings);
|
||||
var config = configurationBuilder.Build();
|
||||
var contrib = RedisHealthContributor.GetRedisContributor(config);
|
||||
Assert.NotNull(contrib);
|
||||
var status = contrib.Health();
|
||||
Assert.Equal(HealthStatus.DOWN, status.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StackExchange_Not_Connected_Returns_Down_Status()
|
||||
{
|
||||
|
|
|
@ -12,17 +12,37 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Steeltoe.CloudFoundry.Connector.RabbitMQ;
|
||||
using Steeltoe.CloudFoundry.Connector.Services;
|
||||
using Steeltoe.Common.HealthChecks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Steeltoe.CloudFoundry.Connector.Test.Queue
|
||||
{
|
||||
public class RabbitMQHealthContributorTest
|
||||
{
|
||||
[Fact]
|
||||
public void GetRabbitMQContributor_ReturnsContributor()
|
||||
{
|
||||
var appsettings = new Dictionary<string, string>()
|
||||
{
|
||||
["rabbit:client:server"] = "localhost",
|
||||
["rabbit:client:port"] = "1234",
|
||||
};
|
||||
|
||||
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
|
||||
configurationBuilder.AddInMemoryCollection(appsettings);
|
||||
var config = configurationBuilder.Build();
|
||||
var contrib = RabbitMQHealthContributor.GetRabbitMQContributor(config);
|
||||
Assert.NotNull(contrib);
|
||||
var status = contrib.Health();
|
||||
Assert.Equal(HealthStatus.DOWN, status.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Not_Connected_Returns_Down_Status()
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Steeltoe.CloudFoundry.Connector.MySql;
|
||||
using Steeltoe.CloudFoundry.Connector.PostgreSql;
|
||||
|
@ -23,6 +24,7 @@ using Steeltoe.CloudFoundry.Connector.Services;
|
|||
using Steeltoe.CloudFoundry.Connector.SqlServer;
|
||||
using Steeltoe.Common.HealthChecks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Xunit;
|
||||
|
||||
|
@ -30,6 +32,67 @@ namespace Steeltoe.CloudFoundry.Connector.Test.Relational
|
|||
{
|
||||
public class RelationalHealthContributorTest
|
||||
{
|
||||
[Fact]
|
||||
public void GetMySqlContributor_ReturnsContributor()
|
||||
{
|
||||
var appsettings = new Dictionary<string, string>()
|
||||
{
|
||||
["mysql:client:server"] = "localhost",
|
||||
["mysql:client:port"] = "1234",
|
||||
["mysql:client:PersistSecurityInfo"] = "true",
|
||||
["mysql:client:password"] = "password",
|
||||
["mysql:client:username"] = "username"
|
||||
};
|
||||
|
||||
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
|
||||
configurationBuilder.AddInMemoryCollection(appsettings);
|
||||
var config = configurationBuilder.Build();
|
||||
var contrib = RelationalHealthContributor.GetMySqlContributor(config);
|
||||
Assert.NotNull(contrib);
|
||||
var status = contrib.Health();
|
||||
Assert.Equal(HealthStatus.DOWN, status.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPostgreSqlContributor_ReturnsContributor()
|
||||
{
|
||||
var appsettings = new Dictionary<string, string>()
|
||||
{
|
||||
["postgres:client:host"] = "localhost",
|
||||
["postgres:client:port"] = "1234",
|
||||
["postgres:client:password"] = "password",
|
||||
["postgres:client:username"] = "username"
|
||||
};
|
||||
|
||||
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
|
||||
configurationBuilder.AddInMemoryCollection(appsettings);
|
||||
var config = configurationBuilder.Build();
|
||||
var contrib = RelationalHealthContributor.GetPostgreSqlContributor(config);
|
||||
Assert.NotNull(contrib);
|
||||
var status = contrib.Health();
|
||||
Assert.Equal(HealthStatus.DOWN, status.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSqlServerContributor_ReturnsContributor()
|
||||
{
|
||||
var appsettings = new Dictionary<string, string>()
|
||||
{
|
||||
["sqlserver:credentials:uid"] = "username",
|
||||
["sqlserver:credentials:uri"] = "jdbc:sqlserver://servername:1433;databaseName=de5aa3a747c134b3d8780f8cc80be519e",
|
||||
["sqlserver:credentials:db"] = "de5aa3a747c134b3d8780f8cc80be519e",
|
||||
["sqlserver:credentials:pw"] = "password"
|
||||
};
|
||||
|
||||
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
|
||||
configurationBuilder.AddInMemoryCollection(appsettings);
|
||||
var config = configurationBuilder.Build();
|
||||
var contrib = RelationalHealthContributor.GetSqlServerContributor(config);
|
||||
Assert.NotNull(contrib);
|
||||
var status = contrib.Health();
|
||||
Assert.Equal(HealthStatus.DOWN, status.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Sql_Not_Connected_Returns_Down_Status()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче