forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update System.Memory.Data (Azure#46134)
* link fixes * Revert "link fixes" This reverts commit 61d9eaa. * update * AOT updates * SCM test fix * update API * Another storage fix * fixes for communication / openai * update snippets * fix * fixes
- Loading branch information
Showing
14 changed files
with
107 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright(c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.ClientModel; | ||
using System.ClientModel.Primitives; | ||
|
||
namespace OpenAI.TestFramework.Mocks; | ||
|
||
/// <summary> | ||
/// Represents a mock page with a collection of values and a reference to the next page. | ||
/// </summary> | ||
/// <typeparam name="TValue">The type of values in the page.</typeparam> | ||
public class MockPage<TValue> | ||
{ | ||
/// <summary> | ||
/// Gets or sets the collection of values in the page. | ||
/// </summary> | ||
required public IReadOnlyList<TValue> Values { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the first item on the next page. | ||
/// </summary> | ||
required public int Next { get; set; } | ||
|
||
/// <summary> | ||
/// Creates a <see cref="MockPage{TValue}"/> instance from a <see cref="ClientResult"/>. | ||
/// </summary> | ||
/// <param name="result">The client result.</param> | ||
/// <returns>The created <see cref="MockPage{TValue}"/> instance.</returns> | ||
public static MockPage<TValue> FromClientResult(ClientResult result) | ||
{ | ||
PipelineResponse response = result.GetRawResponse(); | ||
response.BufferContent(); | ||
MockPage<TValue> mockPage = response.Content.ToObjectFromJson<MockPage<TValue>>() ?? new MockPage<TValue> | ||
{ | ||
Values = [], | ||
Next = 0 | ||
}; | ||
return mockPage; | ||
} | ||
|
||
/// <summary> | ||
/// Converts the <see cref="MockPage{TValue}"/> instance to a <see cref="ClientResult"/>. | ||
/// </summary> | ||
/// <returns>The converted <see cref="ClientResult"/> instance.</returns> | ||
public ClientResult AsClientResult() | ||
{ | ||
var serialized = BinaryData.FromObjectAsJson(this); | ||
var mockResponse = new MockPipelineResponse(content: serialized); | ||
return ClientResult.FromResponse(mockResponse); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters