From 1393368695cab68314d84a1cb008bb512f5bf392 Mon Sep 17 00:00:00 2001 From: sikutisa Date: Sat, 14 Sep 2024 17:20:29 +0900 Subject: [PATCH] update tests Related to: #319 --- .../Repositories/AdminEventRepositoryTests.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/test/AzureOpenAIProxy.ApiApp.Tests/Repositories/AdminEventRepositoryTests.cs b/test/AzureOpenAIProxy.ApiApp.Tests/Repositories/AdminEventRepositoryTests.cs index 0e00c5d4..16266348 100644 --- a/test/AzureOpenAIProxy.ApiApp.Tests/Repositories/AdminEventRepositoryTests.cs +++ b/test/AzureOpenAIProxy.ApiApp.Tests/Repositories/AdminEventRepositoryTests.cs @@ -1,10 +1,17 @@ -using AzureOpenAIProxy.ApiApp.Models; +using Azure.Data.Tables; + +using AzureOpenAIProxy.ApiApp.Configurations; +using AzureOpenAIProxy.ApiApp.Models; using AzureOpenAIProxy.ApiApp.Repositories; +using Castle.Core.Configuration; + using FluentAssertions; using Microsoft.Extensions.DependencyInjection; +using NSubstitute; + namespace AzureOpenAIProxy.ApiApp.Tests.Repositories; public class AdminEventRepositoryTests @@ -26,8 +33,10 @@ public void Given_ServiceCollection_When_AddAdminEventRepository_Invoked_Then_It public void Given_Instance_When_CreateEvent_Invoked_Then_It_Should_Throw_Exception() { // Arrange + var settings = Substitute.For(); + var tableServiceClient = Substitute.For(); var eventDetails = new AdminEventDetails(); - var repository = new AdminEventRepository(); + var repository = new AdminEventRepository(tableServiceClient, settings); // Act Func func = async () => await repository.CreateEvent(eventDetails); @@ -40,7 +49,9 @@ public void Given_Instance_When_CreateEvent_Invoked_Then_It_Should_Throw_Excepti public void Given_Instance_When_GetEvents_Invoked_Then_It_Should_Throw_Exception() { // Arrange - var repository = new AdminEventRepository(); + var settings = Substitute.For(); + var tableServiceClient = Substitute.For(); + var repository = new AdminEventRepository(tableServiceClient, settings); // Act Func func = async () => await repository.GetEvents(); @@ -53,8 +64,10 @@ public void Given_Instance_When_GetEvents_Invoked_Then_It_Should_Throw_Exception public void Given_Instance_When_GetEvent_Invoked_Then_It_Should_Throw_Exception() { // Arrange + var settings = Substitute.For(); + var tableServiceClient = Substitute.For(); var eventId = Guid.NewGuid(); - var repository = new AdminEventRepository(); + var repository = new AdminEventRepository(tableServiceClient, settings); // Act Func func = async () => await repository.GetEvent(eventId); @@ -67,9 +80,11 @@ public void Given_Instance_When_GetEvent_Invoked_Then_It_Should_Throw_Exception( public void Given_Instance_When_UpdateEvent_Invoked_Then_It_Should_Throw_Exception() { // Arrange + var settings = Substitute.For(); + var tableServiceClient = Substitute.For(); var eventId = Guid.NewGuid(); var eventDetails = new AdminEventDetails(); - var repository = new AdminEventRepository(); + var repository = new AdminEventRepository(tableServiceClient, settings); // Act Func func = async () => await repository.UpdateEvent(eventId, eventDetails);