1- using NUnit . Framework ;
1+ using Microsoft . ClientModel . TestFramework ;
2+ using NUnit . Framework ;
23using NUnit . Framework . Internal ;
34using OpenAI . Assistants ;
45using OpenAI . Files ;
5- using OpenAI . Tests . Utility ;
66using OpenAI . VectorStores ;
77using System ;
88using System . ClientModel ;
@@ -19,10 +19,8 @@ namespace OpenAI.Tests.Assistants;
1919
2020#pragma warning disable OPENAI001
2121
22- [ TestFixture ( true ) ]
23- [ TestFixture ( false ) ]
2422[ Category ( "Assistants" ) ]
25- public class AssistantsTests : SyncAsyncTestBase
23+ public class AssistantsTests : ClientTestBase
2624{
2725 private readonly List < Assistant > _assistantsToDelete = [ ] ;
2826 private readonly List < AssistantThread > _threadsToDelete = [ ] ;
@@ -599,11 +597,10 @@ public async Task FunctionToolsWork()
599597 Assert . That ( messages [ 0 ] . Content [ 0 ] . Text . ToLowerInvariant ( ) , Does . Contain ( "tacos" ) ) ;
600598 }
601599
600+ [ AsyncOnly ]
602601 [ Test ]
603602 public async Task StreamingRunWorksAsync ( )
604603 {
605- AssertAsyncOnly ( ) ;
606-
607604 AssistantClient client = GetTestClient ( ) ;
608605 Assistant assistant = await client . CreateAssistantAsync ( "gpt-4o-mini" ) ;
609606 Validate ( assistant ) ;
@@ -649,11 +646,10 @@ AsyncCollectionResult<StreamingUpdate> streamingResult
649646 Print ( ">>> Done <<<" ) ;
650647 }
651648
649+ [ SyncOnly ]
652650 [ Test ]
653651 public void StreamingRunWorks ( )
654652 {
655- AssertSyncOnly ( ) ;
656-
657653 AssistantClient client = GetTestClient ( ) ;
658654 Assistant assistant = client . CreateAssistant ( "gpt-4o-mini" ) ;
659655 Validate ( assistant ) ;
@@ -699,11 +695,10 @@ CollectionResult<StreamingUpdate> streamingResult
699695 Print ( ">>> Done <<<" ) ;
700696 }
701697
698+ [ AsyncOnly ]
702699 [ TestCase ]
703700 public async Task StreamingToolCallAsync ( )
704701 {
705- AssertAsyncOnly ( ) ;
706-
707702 AssistantClient client = GetTestClient ( ) ;
708703 FunctionToolDefinition getWeatherTool = new ( "get_current_weather" )
709704 {
@@ -762,11 +757,10 @@ public async Task StreamingToolCallAsync()
762757 } while ( run ? . Status . IsTerminal == false ) ;
763758 }
764759
760+ [ SyncOnly ]
765761 [ TestCase ]
766762 public void StreamingToolCall ( )
767763 {
768- AssertSyncOnly ( ) ;
769-
770764 AssistantClient client = GetTestClient ( ) ;
771765 FunctionToolDefinition getWeatherTool = new ( "get_current_weather" )
772766 {
@@ -1028,11 +1022,10 @@ This file describes the favorite foods of several people.
10281022 } ) ;
10291023 }
10301024
1025+ [ SyncOnly ]
10311026 [ Test ]
10321027 public void FileSearchStreamingWorksSync ( )
10331028 {
1034- AssertSyncOnly ( ) ;
1035-
10361029 const string fileContent = """
10371030 The favorite food of several people:
10381031 - Summanus Ferdinand: tacos
@@ -1119,11 +1112,10 @@ public void FileSearchStreamingWorksSync()
11191112 Assert . That ( message , Does . Contain ( "cake" ) ) ;
11201113 }
11211114
1115+ [ AsyncOnly ]
11221116 [ Test ]
11231117 public async Task FileSearchStreamingWorksAsync ( )
11241118 {
1125- AssertAsyncOnly ( ) ;
1126-
11271119 const string fileContent = """
11281120 The favorite food of several people:
11291121 - Summanus Ferdinand: tacos
@@ -1212,11 +1204,10 @@ public async Task FileSearchStreamingWorksAsync()
12121204 Assert . That ( message , Does . Contain ( "cake" ) ) ;
12131205 }
12141206
1207+ [ AsyncOnly ]
12151208 [ Test ]
12161209 public async Task Pagination_CanEnumerateAssistantsAsync ( )
12171210 {
1218- AssertAsyncOnly ( ) ;
1219-
12201211 const int TestAssistantCount = 10 ;
12211212
12221213 AssistantClient client = GetTestClient ( ) ;
@@ -1257,11 +1248,10 @@ public async Task Pagination_CanEnumerateAssistantsAsync()
12571248 Assert . That ( count , Is . GreaterThanOrEqualTo ( TestAssistantCount ) ) ;
12581249 }
12591250
1251+ [ SyncOnly ]
12601252 [ Test ]
12611253 public void Pagination_CanEnumerateAssistants ( )
12621254 {
1263- AssertSyncOnly ( ) ;
1264-
12651255 const int TestAssistantCount = 10 ;
12661256
12671257 AssistantClient client = GetTestClient ( ) ;
@@ -1302,11 +1292,10 @@ public void Pagination_CanEnumerateAssistants()
13021292 Assert . That ( count , Is . GreaterThanOrEqualTo ( TestAssistantCount ) ) ;
13031293 }
13041294
1295+ [ AsyncOnly ]
13051296 [ Test ]
13061297 public async Task Pagination_CanPageThroughAssistantCollectionAsync ( )
13071298 {
1308- AssertAsyncOnly ( ) ;
1309-
13101299 const int TestAssistantCount = 10 ;
13111300 const int TestPageSizeLimit = 2 ;
13121301
@@ -1360,11 +1349,10 @@ public async Task Pagination_CanPageThroughAssistantCollectionAsync()
13601349 Assert . That ( pageCount , Is . GreaterThanOrEqualTo ( TestAssistantCount / TestPageSizeLimit ) ) ;
13611350 }
13621351
1352+ [ SyncOnly ]
13631353 [ Test ]
13641354 public void Pagination_CanPageThroughAssistantCollection ( )
13651355 {
1366- AssertSyncOnly ( ) ;
1367-
13681356 const int TestAssistantCount = 10 ;
13691357 const int TestPageSizeLimit = 2 ;
13701358
@@ -1428,11 +1416,10 @@ private static IEnumerable<Assistant> GetAssistantsFromPage(ClientResult page)
14281416 return els . Select ( el => ModelReaderWriter . Read < Assistant > ( BinaryData . FromString ( el . GetRawText ( ) ) ) ) ;
14291417 }
14301418
1419+ [ AsyncOnly ]
14311420 [ Test ]
14321421 public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytesAsync ( )
14331422 {
1434- AssertAsyncOnly ( ) ;
1435-
14361423 const int TestAssistantCount = 10 ;
14371424 const int TestPageSizeLimit = 2 ;
14381425
@@ -1502,11 +1489,10 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytesAsync()
15021489 Assert . That ( pageCount , Is . GreaterThanOrEqualTo ( TestAssistantCount / TestPageSizeLimit ) ) ;
15031490 }
15041491
1492+ [ SyncOnly ]
15051493 [ Test ]
15061494 public void Pagination_CanRehydrateAssistantPageCollectionFromBytes ( )
15071495 {
1508- AssertSyncOnly ( ) ;
1509-
15101496 const int TestAssistantCount = 10 ;
15111497 const int TestPageSizeLimit = 2 ;
15121498
@@ -1577,11 +1563,10 @@ public void Pagination_CanRehydrateAssistantPageCollectionFromBytes()
15771563 Assert . That ( pageCount , Is . GreaterThanOrEqualTo ( TestAssistantCount / TestPageSizeLimit ) ) ;
15781564 }
15791565
1566+ [ AsyncOnly ]
15801567 [ Test ]
15811568 public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageTokenAsync ( )
15821569 {
1583- AssertAsyncOnly ( ) ;
1584-
15851570 const int TestAssistantCount = 10 ;
15861571 const int TestPageSizeLimit = 2 ;
15871572
@@ -1661,11 +1646,10 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageTokenAsy
16611646 Assert . That ( pageCount , Is . GreaterThanOrEqualTo ( TestAssistantCount / TestPageSizeLimit ) ) ;
16621647 }
16631648
1649+ [ SyncOnly ]
16641650 [ Test ]
16651651 public void Pagination_CanRehydrateAssistantPageCollectionFromPageToken ( )
16661652 {
1667- AssertSyncOnly ( ) ;
1668-
16691653 const int TestAssistantCount = 10 ;
16701654 const int TestPageSizeLimit = 2 ;
16711655
@@ -1744,11 +1728,10 @@ public void Pagination_CanRehydrateAssistantPageCollectionFromPageToken()
17441728 Assert . That ( pageCount , Is . GreaterThanOrEqualTo ( TestAssistantCount / TestPageSizeLimit ) ) ;
17451729 }
17461730
1731+ [ AsyncOnly ]
17471732 [ Test ]
17481733 public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytesAsync ( )
17491734 {
1750- AssertAsyncOnly ( ) ;
1751-
17521735 AssistantClient client = GetTestClient ( ) ;
17531736 Assistant assistant = client . CreateAssistant ( "gpt-4o" , new AssistantCreationOptions ( )
17541737 {
@@ -1824,14 +1807,13 @@ public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytesAsync()
18241807 . ToListAsync ( ) ;
18251808 }
18261809
1827- CollectionAssert . AreEqual ( runSteps , rehydratedRunSteps ) ;
1810+ Assert . That ( rehydratedRunSteps , Is . EqualTo ( runSteps ) . AsCollection ) ;
18281811 }
18291812
1813+ [ SyncOnly ]
18301814 [ Test ]
18311815 public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytes ( )
18321816 {
1833- AssertSyncOnly ( ) ;
1834-
18351817 AssistantClient client = GetTestClient ( ) ;
18361818 Assistant assistant = client . CreateAssistant ( "gpt-4o" , new AssistantCreationOptions ( )
18371819 {
@@ -1907,7 +1889,7 @@ public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytes()
19071889 . ToList ( ) ;
19081890 }
19091891
1910- CollectionAssert . AreEqual ( runSteps , rehydratedRunSteps ) ;
1892+ Assert . That ( rehydratedRunSteps , Is . EqualTo ( runSteps ) . AsCollection ) ;
19111893 }
19121894
19131895 [ Test ]
0 commit comments