Skip to content

Commit

Permalink
Assert -> Shouldly
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r committed Jul 30, 2023
1 parent d5c238b commit 49f099b
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void fail_when_no_health_check_configuration_provided()

var registration = options.Value.Registrations.First();

Assert.Throws<ArgumentNullException>(() => registration.Factory(serviceProvider));
Should.Throw<ArgumentNullException>(() => registration.Factory(serviceProvider));
}

[Fact]
Expand Down Expand Up @@ -117,6 +117,6 @@ public void fail_when_no_health_check_configuration_provided_by_credentials()

var registration = options.Value.Registrations.First();

Assert.Throws<ArgumentNullException>(() => registration.Factory(serviceProvider));
Should.Throw<ArgumentNullException>(() => registration.Factory(serviceProvider));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void fail_when_no_health_check_configuration_provided()

var registration = options.Value.Registrations.First();

Assert.Throws<ArgumentNullException>(() => registration.Factory(serviceProvider));
Should.Throw<ArgumentNullException>(() => registration.Factory(serviceProvider));
}

[Fact]
Expand Down Expand Up @@ -117,6 +117,6 @@ public void fail_when_no_health_check_configuration_provided_by_credentials()

var registration = options.Value.Registrations.First();

Assert.Throws<ArgumentNullException>(() => registration.Factory(serviceProvider));
Should.Throw<ArgumentNullException>(() => registration.Factory(serviceProvider));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void fail_when_no_health_check_configuration_provided()

var registration = options.Value.Registrations.First();

Assert.Throws<ArgumentNullException>(() => registration.Factory(serviceProvider));
Should.Throw<ArgumentNullException>(() => registration.Factory(serviceProvider));
}

[Fact]
Expand Down Expand Up @@ -97,6 +97,6 @@ public void fail_when_no_health_check_configuration_provided_by_credentials()

var registration = options.Value.Registrations.First();

Assert.Throws<ArgumentNullException>(() => registration.Factory(serviceProvider));
Should.Throw<ArgumentNullException>(() => registration.Factory(serviceProvider));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void fail_when_invalid_uri_provided_in_configuration()
{
var services = new ServiceCollection();

Assert.Throws<ArgumentNullException>(() =>
Should.Throw<ArgumentNullException>(() =>
{
services.AddHealthChecks()
.AddAzureKeyVault(null!, new MockTokenCredentials(), setup =>
Expand All @@ -65,7 +65,7 @@ public void fail_when_invalid_uri_provided_with_service_provider_based_setup_in_
{
var services = new ServiceCollection();

Assert.Throws<ArgumentNullException>(() =>
Should.Throw<ArgumentNullException>(() =>
{
services.AddHealthChecks()
.AddAzureKeyVault((Uri)null!, new MockTokenCredentials(), (_, setup) =>
Expand All @@ -82,7 +82,7 @@ public void fail_when_invalid_credential_provided_in_configuration()
{
var services = new ServiceCollection();

Assert.Throws<ArgumentNullException>(() =>
Should.Throw<ArgumentNullException>(() =>
{
services.AddHealthChecks()
.AddAzureKeyVault(new Uri("http://localhost"), null!, setup =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void add_healthcheck_when_properly_configured_with_instrumentation_key_pa
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}

[Fact]
Expand All @@ -29,7 +29,7 @@ public void add_healthcheck_when_properly_configured_with_connection_string_para
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}

[Fact]
Expand All @@ -47,6 +47,6 @@ public void add_healthcheck_when_application_insights_is_properly_configured_wit
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void add_healthcheck_when_properly_configured_with_default_parameter()
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}

[Fact]
Expand All @@ -27,7 +27,7 @@ public void add_healthcheck_when_properly_configured_with_custom_service_check_n
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}

[Fact]
Expand All @@ -46,7 +46,7 @@ public void add_healthcheck_when_properly_configured_with_default_service_check_
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}

[Fact]
Expand All @@ -66,6 +66,6 @@ public void add_healthcheck_when_properly_configured_with_custom_service_check_n
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public void add_healthcheck_when_properly_configured()
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public void add_healthcheck_when_properly_configured()
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public void add_healthcheck_when_properly_configured()
using var serviceProvider = services.BuildServiceProvider();
var publisher = serviceProvider.GetService<IHealthCheckPublisher>();

Assert.NotNull(publisher);
publisher.ShouldNotBeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void invoke_beforeOpen_when_defined()
Action<SqlConnection> beforeOpen = connection =>
{
invoked = true;
Assert.Equal(connectionstring, connection.ConnectionString);
connection.ConnectionString.ShouldBe(connectionstring);
};
services.AddHealthChecks()
.AddSqlServer(connectionstring, configure: beforeOpen);
Expand All @@ -42,7 +42,7 @@ public void invoke_beforeOpen_when_defined()
var check = registration.Factory(serviceProvider);

Record.ExceptionAsync(() => check.CheckHealthAsync(new HealthCheckContext())).GetAwaiter().GetResult();
Assert.True(invoked);
invoked.ShouldBeTrue();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public void throw_exception_when_no_predicate_is_configured()
{
var services = new ServiceCollection();

var ex = Assert.Throws<ArgumentNullException>(() =>
var ex = Should.Throw<ArgumentNullException>(() =>
{
services.AddHealthChecks()
.AddProcessHealthCheck("dotnet", null!);
Expand All @@ -21,7 +21,7 @@ public void throw_exception_when_no_process_name_is_configured()
{
var services = new ServiceCollection();

var ex = Assert.Throws<ArgumentNullException>(() => services.AddHealthChecks().AddProcessHealthCheck("", p => p.Length > 0));
var ex = Should.Throw<ArgumentNullException>(() => services.AddHealthChecks().AddProcessHealthCheck("", p => p.Length > 0));

ex.Message.ShouldBe("Value cannot be null. (Parameter 'processName')");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void throw_exception_when_registering_it_in_a_no_windows_system()
});
});

var exception = Assert.Throws<PlatformNotSupportedException>(() =>
var exception = Should.Throw<PlatformNotSupportedException>(() =>
{
using var server = new TestServer(webhostBuilder);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void fail_with_invalid_storage_provider_value()
})
.UseStartup<Startup>();

Assert.Throws<ArgumentException>(() => hostBuilder.Build());
Should.Throw<ArgumentException>(() => hostBuilder.Build());
}
[Fact]
public void register_sql_server()
Expand Down Expand Up @@ -67,7 +67,7 @@ public void fail_to_register_sql_server_with_no_connection_string()
})
.UseStartup<Startup>();

Assert.Throws<ArgumentNullException>(() => hostBuilder.Build());
Should.Throw<ArgumentNullException>(() => hostBuilder.Build());
}

[Fact]
Expand Down Expand Up @@ -107,7 +107,7 @@ public void fail_to_register_sqlite_with_no_connection_string()
})
.UseStartup<Startup>();

Assert.Throws<ArgumentNullException>(() => hostBuilder.Build());
Should.Throw<ArgumentNullException>(() => hostBuilder.Build());
}

[Fact]
Expand Down Expand Up @@ -147,7 +147,7 @@ public void fail_to_register_postgresql_with_no_connection_string()
})
.UseStartup<Startup>();

Assert.Throws<ArgumentNullException>(() => hostBuilder.Build());
Should.Throw<ArgumentNullException>(() => hostBuilder.Build());
}

[Fact]
Expand Down Expand Up @@ -223,7 +223,7 @@ public void fail_to_register_mysql_with_no_connection_string()
})
.UseStartup<Startup>();

Assert.Throws<ArgumentNullException>(() => hostBuilder.Build());
Should.Throw<ArgumentNullException>(() => hostBuilder.Build());
}

}
Expand Down

0 comments on commit 49f099b

Please sign in to comment.