Skip to content

Commit c03125b

Browse files
committed
add argument tests when creating AdminEventRepository
Related to: aliencube#319
1 parent ea8c726 commit c03125b

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public interface IAdminEventRepository
4545
/// </summary>
4646
public class AdminEventRepository(TableServiceClient tableServiceClient, StorageAccountSettings storageAccountSettings) : IAdminEventRepository
4747
{
48-
private readonly TableServiceClient _tableServiceClient = tableServiceClient ?? throw new ArgumentException(nameof(tableServiceClient));
49-
private readonly StorageAccountSettings _storageAccountSettings = storageAccountSettings ?? throw new ArgumentException(nameof(storageAccountSettings));
48+
private readonly TableServiceClient _tableServiceClient = tableServiceClient ?? throw new ArgumentNullException(nameof(tableServiceClient));
49+
private readonly StorageAccountSettings _storageAccountSettings = storageAccountSettings ?? throw new ArgumentNullException(nameof(storageAccountSettings));
5050

5151
/// <inheritdoc />
5252
public async Task<AdminEventDetails> CreateEvent(AdminEventDetails eventDetails)

test/AzureOpenAIProxy.ApiApp.Tests/Repositories/AdminEventRepositoryTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,34 @@ public void Given_ServiceCollection_When_AddAdminEventRepository_Invoked_Then_It
2929
services.SingleOrDefault(p => p.ServiceType == typeof(IAdminEventRepository)).Should().NotBeNull();
3030
}
3131

32+
[Fact]
33+
public void Given_Null_TableServiceClient_When_Creating_AdminEventRepository_Then_It_Should_Throw_Exception()
34+
{
35+
// Arrange
36+
var settings = Substitute.For<StorageAccountSettings>();
37+
var tableServiceClient = default(TableServiceClient);
38+
39+
// Act
40+
Action action = () => new AdminEventRepository(tableServiceClient, settings);
41+
42+
// Assert
43+
action.Should().Throw<ArgumentNullException>();
44+
}
45+
46+
[Fact]
47+
public void Given_Null_StorageAccountSettings_When_Creating_AdminEventRepository_Then_It_Should_Throw_Exception()
48+
{
49+
// Arrange
50+
var settings = default(StorageAccountSettings);
51+
var tableServiceClient = Substitute.For<TableServiceClient>();
52+
53+
// Act
54+
Action action = () => new AdminEventRepository(tableServiceClient, settings);
55+
56+
// Assert
57+
action.Should().Throw<ArgumentNullException>();
58+
}
59+
3260
[Fact]
3361
public void Given_Instance_When_CreateEvent_Invoked_Then_It_Should_Throw_Exception()
3462
{

0 commit comments

Comments
 (0)