Skip to content

Commit 4d45202

Browse files
Copilotsamtrion
andcommitted
test: Complete NetEvolve.HealthChecks.Azure.Kusto implementation with tests
Co-authored-by: samtrion <[email protected]>
1 parent cd239e7 commit 4d45202

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

src/NetEvolve.HealthChecks.Azure.Kusto/KustoOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public sealed record KustoOptions : IKustoOptions
2626
/// <summary>
2727
/// Gets or sets the mode to create the client.
2828
/// </summary>
29-
public KustoClientCreationMode? Mode { get; set; }
29+
public KustoClientCreationMode? Mode { get; set; } = KustoClientCreationMode.ConnectionString;
3030

3131
/// <summary>
3232
/// The timeout to use when connecting and executing tasks against Kusto.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
namespace NetEvolve.HealthChecks.Tests.Unit.Azure.Kusto;
2+
3+
using System;
4+
using System.Threading.Tasks;
5+
using Microsoft.Extensions.DependencyInjection;
6+
using NetEvolve.Extensions.TUnit;
7+
using NetEvolve.HealthChecks.Azure.Kusto;
8+
9+
[TestGroup($"{nameof(Azure)}.{nameof(Kusto)}")]
10+
public sealed class DependencyInjectionExtensionsTests
11+
{
12+
[Test]
13+
public async Task AddKusto_WhenArgumentBuilderNull_ThrowArgumentNullException()
14+
{
15+
// Arrange & Act & Assert
16+
_ = await Assert
17+
.That(() => DependencyInjectionExtensions.AddKusto(null!, "Test"))
18+
.Throws<ArgumentNullException>()
19+
.And.HasParameterName("builder");
20+
}
21+
22+
[Test]
23+
public async Task AddKusto_WhenArgumentNameNull_ThrowArgumentException()
24+
{
25+
// Arrange
26+
var services = new ServiceCollection();
27+
var builder = services.AddHealthChecks();
28+
29+
// Act & Assert
30+
_ = await Assert
31+
.That(() => builder.AddKusto(null!))
32+
.Throws<ArgumentException>()
33+
.And.HasParameterName("name");
34+
}
35+
36+
[Test]
37+
public async Task AddKusto_WhenArgumentNameEmpty_ThrowArgumentException()
38+
{
39+
// Arrange
40+
var services = new ServiceCollection();
41+
var builder = services.AddHealthChecks();
42+
43+
// Act & Assert
44+
_ = await Assert
45+
.That(() => builder.AddKusto(string.Empty))
46+
.Throws<ArgumentException>()
47+
.And.HasParameterName("name");
48+
}
49+
50+
[Test]
51+
public async Task AddKusto_WhenArgumentTagsNull_ThrowArgumentNullException()
52+
{
53+
// Arrange
54+
var services = new ServiceCollection();
55+
var builder = services.AddHealthChecks();
56+
57+
// Act & Assert
58+
_ = await Assert
59+
.That(() => builder.AddKusto("Test", null, null!))
60+
.Throws<ArgumentNullException>()
61+
.And.HasParameterName("tags");
62+
}
63+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace NetEvolve.HealthChecks.Tests.Unit.Azure.Kusto;
2+
3+
using System.Threading.Tasks;
4+
using NetEvolve.Extensions.TUnit;
5+
using NetEvolve.HealthChecks.Azure.Kusto;
6+
7+
[TestGroup($"{nameof(Azure)}.{nameof(Kusto)}")]
8+
public sealed class KustoOptionsTests
9+
{
10+
[Test]
11+
public async Task Options_NotSame_Expected()
12+
{
13+
var options1 = new KustoOptions();
14+
var options2 = options1 with { };
15+
16+
_ = await Assert.That(options1).IsEqualTo(options2).And.IsNotSameReferenceAs(options2);
17+
}
18+
}

0 commit comments

Comments
 (0)