Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
notatiyyah committed Mar 11, 2024
1 parent ed93de8 commit 1be6807
Showing 1 changed file with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
using FluentAssertions;
using Hackney.Core.DynamoDb.HealthCheck;
using Hackney.Core.Testing.Shared;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Moq;
using Xunit;

namespace Hackney.Core.Tests.DynamoDb.HealthCheck
{
public class DynamoDbHealthCheckExtensionsTests
{

[Fact]
public void RegisterDynamoDbHealthCheckTest()
{
var services = new ServiceCollection();
_ = services.RegisterDynamoDbHealthCheck<TestModelDb>();

services.IsServiceRegistered<IHealthCheck, DynamoDbHealthCheck<TestModelDb>>().Should().BeTrue();
}

[Fact]
public void ServiceCollectionAddDynamoDbHealthCheckTest()
{
var services = new ServiceCollection();
_ = services.AddDynamoDbHealthCheck<TestModelDb>();

services.IsServiceRegistered<IHealthCheck, DynamoDbHealthCheck<TestModelDb>>().Should().BeTrue();

// We can't explicitly verify the Healthcheck builder reigstration here as it is not accessible.
// We have to reply on the test below to do that for us.
}

[Fact]
public void HealthChecksBuilderAddDynamoDbHealthCheckTest()
{
var mockBuilder = new Mock<IHealthChecksBuilder>();
_ = mockBuilder.Object.AddDynamoDbHealthCheck<TestModelDb>();

mockBuilder.Verify(x => x.Add(It.Is<HealthCheckRegistration>(hcr => hcr.Name == "DynamoDb"
&& hcr.Factory != null)), Times.Once);
}
}
}
using FluentAssertions;
using Hackney.Core.DynamoDb.HealthCheck;
using Hackney.Core.Testing.Shared;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Moq;
using Xunit;

namespace Hackney.Core.Tests.DynamoDb.HealthCheck
{
public class DynamoDbHealthCheckExtensionsTests
{

[Fact]
public void RegisterDynamoDbHealthCheckTest()
{
var services = new ServiceCollection();
_ = services.RegisterDynamoDbHealthCheck<TestModelDb>();

services.IsServiceRegistered<IHealthCheck, DynamoDbHealthCheck<TestModelDb>>().Should().BeTrue();
}

[Fact]
public void ServiceCollectionAddDynamoDbHealthCheckTest()
{
var services = new ServiceCollection();
_ = services.AddDynamoDbHealthCheck<TestModelDb>();

services.IsServiceRegistered<IHealthCheck, DynamoDbHealthCheck<TestModelDb>>().Should().BeTrue();

// We can't explicitly verify the Healthcheck builder reigstration here as it is not accessible.
// We have to reply on the test below to do that for us.
}

[Fact]
public void HealthChecksBuilderAddDynamoDbHealthCheckTest()
{
var mockBuilder = new Mock<IHealthChecksBuilder>();
_ = mockBuilder.Object.AddDynamoDbHealthCheck<TestModelDb>();

mockBuilder.Verify(x => x.Add(It.Is<HealthCheckRegistration>(hcr => hcr.Name == "DynamoDb_" + typeof(TestModelDb).Name
&& hcr.Factory != null)), Times.Once);
}
}
}

0 comments on commit 1be6807

Please sign in to comment.