Skip to content

Commit

Permalink
test: add unit-tests for QueryIdProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
perkops committed Aug 20, 2024
1 parent e86bdc1 commit 7b7ccde
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/Atc.Kusto.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
global using Atc.Kusto.Extensions.Internal;
global using Atc.Kusto.Extensions.Internal;
global using Atc.Kusto.Providers.Internal;
33 changes: 33 additions & 0 deletions test/Atc.Kusto.Tests/Providers/Internal/QueryIdProviderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Atc.Kusto.Tests.Providers.Internal;

public sealed class QueryIdProviderTests
{
private readonly QueryIdProvider sut = new();

[Theory, AutoNSubstituteData]
public void Create_WithValidSessionId_ReturnsExpectedQueryId(
Type queryType,
string sessionId)
{
// Arrange & Act
var actual = sut.Create(queryType, sessionId);

// Assert
actual
.Should()
.Be($"{queryType.Name}{sessionId.ToAlphaNumeric()}");
}

[Theory, AutoNSubstituteData]
public void Create_WithNullSessionId_ReturnsQueryIdWithNewGuid(
Type queryType)
{
// Arrange & Act
var actual = sut.Create(queryType, sessionId: null);

// Assert
actual
.Should().StartWith(queryType.Name)
.And.HaveLength(queryType.Name.Length + Guid.NewGuid().ToString("N").Length);
}
}

0 comments on commit 7b7ccde

Please sign in to comment.