Skip to content

Commit 202a363

Browse files
committed
initial pass on moving to unbranded test framework
1 parent aa0baf8 commit 202a363

37 files changed

+146
-490
lines changed

tests/Assistants/Assistants.VectorStoresTests.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using NUnit.Framework;
1+
using Microsoft.ClientModel.TestFramework;
2+
using NUnit.Framework;
23
using OpenAI.Files;
3-
using OpenAI.Tests.Utility;
44
using OpenAI.VectorStores;
55
using System;
66
using System.ClientModel;
@@ -16,8 +16,7 @@ namespace OpenAI.Tests.VectorStores;
1616

1717
#pragma warning disable OPENAI001
1818

19-
[TestFixture(true)]
20-
[TestFixture(false)]
19+
[ClientTestFixture]
2120
[Category("Assistants")]
2221
public class VectorStoresTests : SyncAsyncTestBase
2322
{
@@ -118,11 +117,10 @@ public async Task CanCreateGetAndDeleteVectorStores()
118117
});
119118
}
120119

120+
[SyncOnly]
121121
[Test]
122122
public void CanEnumerateVectorStores()
123123
{
124-
AssertSyncOnly();
125-
126124
VectorStoreClient client = GetTestClient();
127125
for (int i = 0; i < 10; i++)
128126
{
@@ -158,11 +156,10 @@ public void CanEnumerateVectorStores()
158156
Assert.That(lastIdSeen, Is.EqualTo(0));
159157
}
160158

159+
[AsyncOnly]
161160
[Test]
162161
public async Task CanEnumerateVectorStoresAsync()
163162
{
164-
AssertAsyncOnly();
165-
166163
VectorStoreClient client = GetTestClient();
167164
for (int i = 0; i < 5; i++)
168165
{
@@ -264,11 +261,10 @@ public async Task CanAssociateFiles()
264261
Assert.That(count, Is.EqualTo(2));
265262
}
266263

264+
[AsyncOnly]
267265
[Test]
268266
public async Task Pagination_CanRehydrateFileAssociationCollectionAsync()
269267
{
270-
AssertAsyncOnly();
271-
272268
VectorStoreClient client = GetTestClient();
273269
CreateVectorStoreOperation createOperation = await client.CreateVectorStoreAsync(waitUntilCompleted: false);
274270
VectorStore vectorStore = createOperation.Value;
@@ -346,11 +342,10 @@ public async Task Pagination_CanRehydrateFileAssociationCollectionAsync()
346342
Assert.That(pageCount, Is.EqualTo(2));
347343
}
348344

345+
[SyncOnly]
349346
[Test]
350347
public void Pagination_CanRehydrateFileAssociationCollection()
351348
{
352-
AssertSyncOnly();
353-
354349
VectorStoreClient client = GetTestClient();
355350
CreateVectorStoreOperation createOperation = client.CreateVectorStore(waitUntilCompleted: true);
356351
VectorStore vectorStore = createOperation.Value;

tests/Assistants/AssistantsTests.cs

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using NUnit.Framework;
1+
using Microsoft.ClientModel.TestFramework;
2+
using NUnit.Framework;
23
using OpenAI.Assistants;
34
using OpenAI.Files;
4-
using OpenAI.Tests.Utility;
55
using OpenAI.VectorStores;
66
using System;
77
using System.ClientModel;
@@ -598,11 +598,10 @@ public async Task FunctionToolsWork()
598598
Assert.That(messages[0].Content[0].Text.ToLowerInvariant(), Does.Contain("tacos"));
599599
}
600600

601+
[AsyncOnly]
601602
[Test]
602603
public async Task StreamingRunWorksAsync()
603604
{
604-
AssertAsyncOnly();
605-
606605
AssistantClient client = GetTestClient();
607606
Assistant assistant = await client.CreateAssistantAsync("gpt-4o-mini");
608607
Validate(assistant);
@@ -648,11 +647,10 @@ AsyncCollectionResult<StreamingUpdate> streamingResult
648647
Print(">>> Done <<<");
649648
}
650649

650+
[SyncOnly]
651651
[Test]
652652
public void StreamingRunWorks()
653653
{
654-
AssertSyncOnly();
655-
656654
AssistantClient client = GetTestClient();
657655
Assistant assistant = client.CreateAssistant("gpt-4o-mini");
658656
Validate(assistant);
@@ -698,11 +696,10 @@ CollectionResult<StreamingUpdate> streamingResult
698696
Print(">>> Done <<<");
699697
}
700698

699+
[AsyncOnly]
701700
[TestCase]
702701
public async Task StreamingToolCallAsync()
703702
{
704-
AssertAsyncOnly();
705-
706703
AssistantClient client = GetTestClient();
707704
FunctionToolDefinition getWeatherTool = new("get_current_weather")
708705
{
@@ -761,11 +758,10 @@ public async Task StreamingToolCallAsync()
761758
} while (run?.Status.IsTerminal == false);
762759
}
763760

761+
[SyncOnly]
764762
[TestCase]
765763
public void StreamingToolCall()
766764
{
767-
AssertSyncOnly();
768-
769765
AssistantClient client = GetTestClient();
770766
FunctionToolDefinition getWeatherTool = new("get_current_weather")
771767
{
@@ -1027,11 +1023,10 @@ This file describes the favorite foods of several people.
10271023
});
10281024
}
10291025

1026+
[SyncOnly]
10301027
[Test]
10311028
public void FileSearchStreamingWorksSync()
10321029
{
1033-
AssertSyncOnly();
1034-
10351030
const string fileContent = """
10361031
The favorite food of several people:
10371032
- Summanus Ferdinand: tacos
@@ -1118,11 +1113,10 @@ public void FileSearchStreamingWorksSync()
11181113
Assert.That(message, Does.Contain("cake"));
11191114
}
11201115

1116+
[AsyncOnly]
11211117
[Test]
11221118
public async Task FileSearchStreamingWorksAsync()
11231119
{
1124-
AssertAsyncOnly();
1125-
11261120
const string fileContent = """
11271121
The favorite food of several people:
11281122
- Summanus Ferdinand: tacos
@@ -1211,11 +1205,10 @@ public async Task FileSearchStreamingWorksAsync()
12111205
Assert.That(message, Does.Contain("cake"));
12121206
}
12131207

1208+
[AsyncOnly]
12141209
[Test]
12151210
public async Task Pagination_CanEnumerateAssistantsAsync()
12161211
{
1217-
AssertAsyncOnly();
1218-
12191212
const int TestAssistantCount = 10;
12201213

12211214
AssistantClient client = GetTestClient();
@@ -1256,11 +1249,10 @@ public async Task Pagination_CanEnumerateAssistantsAsync()
12561249
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
12571250
}
12581251

1252+
[SyncOnly]
12591253
[Test]
12601254
public void Pagination_CanEnumerateAssistants()
12611255
{
1262-
AssertSyncOnly();
1263-
12641256
const int TestAssistantCount = 10;
12651257

12661258
AssistantClient client = GetTestClient();
@@ -1301,11 +1293,10 @@ public void Pagination_CanEnumerateAssistants()
13011293
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
13021294
}
13031295

1296+
[AsyncOnly]
13041297
[Test]
13051298
public async Task Pagination_CanPageThroughAssistantCollectionAsync()
13061299
{
1307-
AssertAsyncOnly();
1308-
13091300
const int TestAssistantCount = 10;
13101301
const int TestPageSizeLimit = 2;
13111302

@@ -1359,11 +1350,10 @@ public async Task Pagination_CanPageThroughAssistantCollectionAsync()
13591350
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
13601351
}
13611352

1353+
[SyncOnly]
13621354
[Test]
13631355
public void Pagination_CanPageThroughAssistantCollection()
13641356
{
1365-
AssertSyncOnly();
1366-
13671357
const int TestAssistantCount = 10;
13681358
const int TestPageSizeLimit = 2;
13691359

@@ -1427,11 +1417,10 @@ private static IEnumerable<Assistant> GetAssistantsFromPage(ClientResult page)
14271417
return els.Select(el => ModelReaderWriter.Read<Assistant>(BinaryData.FromString(el.GetRawText())));
14281418
}
14291419

1420+
[AsyncOnly]
14301421
[Test]
14311422
public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytesAsync()
14321423
{
1433-
AssertAsyncOnly();
1434-
14351424
const int TestAssistantCount = 10;
14361425
const int TestPageSizeLimit = 2;
14371426

@@ -1495,11 +1484,10 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytesAsync()
14951484
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
14961485
}
14971486

1487+
[SyncOnly]
14981488
[Test]
14991489
public void Pagination_CanRehydrateAssistantPageCollectionFromBytes()
15001490
{
1501-
AssertSyncOnly();
1502-
15031491
const int TestAssistantCount = 10;
15041492
const int TestPageSizeLimit = 2;
15051493

@@ -1564,11 +1552,10 @@ public void Pagination_CanRehydrateAssistantPageCollectionFromBytes()
15641552
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
15651553
}
15661554

1555+
[AsyncOnly]
15671556
[Test]
15681557
public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageTokenAsync()
15691558
{
1570-
AssertAsyncOnly();
1571-
15721559
const int TestAssistantCount = 10;
15731560
const int TestPageSizeLimit = 2;
15741561

@@ -1643,11 +1630,10 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageTokenAsy
16431630
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
16441631
}
16451632

1633+
[SyncOnly]
16461634
[Test]
16471635
public void Pagination_CanRehydrateAssistantPageCollectionFromPageToken()
16481636
{
1649-
AssertSyncOnly();
1650-
16511637
const int TestAssistantCount = 10;
16521638
const int TestPageSizeLimit = 2;
16531639

@@ -1721,11 +1707,10 @@ public void Pagination_CanRehydrateAssistantPageCollectionFromPageToken()
17211707
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
17221708
}
17231709

1710+
[AsyncOnly]
17241711
[Test]
17251712
public async Task Pagination_CanCastAssistantPageCollectionToConvenienceFromProtocolAsync()
17261713
{
1727-
AssertAsyncOnly();
1728-
17291714
const int TestAssistantCount = 10;
17301715
const int TestPageSizeLimit = 2;
17311716

@@ -1771,11 +1756,10 @@ public async Task Pagination_CanCastAssistantPageCollectionToConvenienceFromProt
17711756
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
17721757
}
17731758

1759+
[SyncOnly]
17741760
[Test]
17751761
public void Pagination_CanCastAssistantPageCollectionToConvenienceFromProtocol()
17761762
{
1777-
AssertSyncOnly();
1778-
17791763
const int TestAssistantCount = 10;
17801764
const int TestPageSizeLimit = 2;
17811765

@@ -1821,11 +1805,10 @@ public void Pagination_CanCastAssistantPageCollectionToConvenienceFromProtocol()
18211805
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
18221806
}
18231807

1808+
[AsyncOnly]
18241809
[Test]
18251810
public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytesAsync()
18261811
{
1827-
AssertAsyncOnly();
1828-
18291812
AssistantClient client = GetTestClient();
18301813
Assistant assistant = client.CreateAssistant("gpt-4o", new AssistantCreationOptions()
18311814
{
@@ -1896,11 +1879,10 @@ public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytesAsync()
18961879
CollectionAssert.AreEqual(runSteps, rehydratedRunSteps);
18971880
}
18981881

1882+
[SyncOnly]
18991883
[Test]
19001884
public void Pagination_CanRehydrateRunStepPageCollectionFromBytes()
19011885
{
1902-
AssertSyncOnly();
1903-
19041886
AssistantClient client = GetTestClient();
19051887
Assistant assistant = client.CreateAssistant("gpt-4o", new AssistantCreationOptions()
19061888
{

tests/Audio/GenerateSpeechMockTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System;
22
using System.ClientModel;
33
using System.Threading;
4+
using Microsoft.ClientModel.TestFramework;
45
using NUnit.Framework;
56
using OpenAI.Audio;
6-
using OpenAI.Tests.Utility;
77

88
namespace OpenAI.Tests.Audio;
99

tests/Audio/GenerateSpeechTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using NUnit.Framework;
1+
using Microsoft.ClientModel.TestFramework;
2+
using NUnit.Framework;
23
using OpenAI.Audio;
3-
using OpenAI.Tests.Utility;
44
using System;
55
using System.Text;
66
using System.Threading.Tasks;

tests/Audio/TranscriptionMockTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
using System.Linq;
55
using System.Threading;
66
using System.Threading.Tasks;
7+
using Microsoft.ClientModel.TestFramework;
8+
using Microsoft.ClientModel.TestFramework.Mocks;
79
using NUnit.Framework;
810
using OpenAI.Audio;
9-
using OpenAI.Tests.Utility;
1011

1112
namespace OpenAI.Tests.Audio;
1213

@@ -160,12 +161,11 @@ public void TranscribeAudioFromStreamRespectsTheCancellationToken()
160161

161162
private OpenAIClientOptions GetClientOptionsWithMockResponse(int status, string content)
162163
{
163-
MockPipelineResponse response = new MockPipelineResponse(status);
164-
response.SetContent(content);
164+
MockPipelineResponse response = new MockPipelineResponse(status).WithContent(content);
165165

166166
return new OpenAIClientOptions()
167167
{
168-
Transport = new MockPipelineTransport(response)
168+
Transport = new MockPipelineTransport(_ => response)
169169
};
170170
}
171171

tests/Audio/TranscriptionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using NUnit.Framework;
1+
using Microsoft.ClientModel.TestFramework;
2+
using NUnit.Framework;
23
using OpenAI.Audio;
3-
using OpenAI.Tests.Utility;
44
using System;
55
using System.ClientModel;
66
using System.ClientModel.Primitives;

tests/Audio/TranslationMockTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
using System.Linq;
55
using System.Threading;
66
using System.Threading.Tasks;
7+
using Microsoft.ClientModel.TestFramework;
8+
using Microsoft.ClientModel.TestFramework.Mocks;
79
using NUnit.Framework;
810
using OpenAI.Audio;
9-
using OpenAI.Tests.Utility;
1011

1112
namespace OpenAI.Tests.Audio;
1213

@@ -136,12 +137,11 @@ public void TranslateAudioFromStreamRespectsTheCancellationToken()
136137

137138
private OpenAIClientOptions GetClientOptionsWithMockResponse(int status, string content = null)
138139
{
139-
MockPipelineResponse response = new MockPipelineResponse(status);
140-
response.SetContent(content ?? "{}");
140+
MockPipelineResponse response = new MockPipelineResponse(status).WithContent(content ?? "{}");
141141

142142
return new OpenAIClientOptions()
143143
{
144-
Transport = new MockPipelineTransport(response)
144+
Transport = new MockPipelineTransport(_ => response)
145145
};
146146
}
147147

0 commit comments

Comments
 (0)