Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Expand_WithSingleNestedProperty_ProducesNestedExpandSyntax()
/// Tests that multiple independent expands still work correctly.
/// </summary>
[Fact]
public void Expand_WithMultipleIndependentProperties_ProducesCommaSepa�ratedExpands()
public void Expand_WithMultipleIndependentProperties_ProducesCommaSeparatedExpands()
{
// Arrange
var builder = new ODataQueryBuilder<Person>("People", NullLogger.Instance);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Net.Http.Headers;

namespace PanoramicData.OData.Client.Test.UnitTests;

/// <summary>
Expand Down Expand Up @@ -36,6 +38,30 @@ public void Dispose()
GC.SuppressFinalize(this);
}

/// <summary>
/// Verifies that the HTTP content written to the stream includes the required headers
/// </summary>
[Fact]
public async Task WriteToStreamAsync_ShouldIncludeRequiredHeaders()
{
using var request = new HttpRequestMessage(HttpMethod.Post, "http://test.org/Customers");
request.Content = new StringContent("{\"Name\":\"Test\"}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

using var content = new HttpMessageContent(request);

// Act
var resultString = await content.ReadAsStringAsync(TestContext.Current.CancellationToken);

// Assert: Check the HttpContent headers specifically
content.Headers.TryGetValues("Content-Transfer-Encoding", out var values);
values.Should().Contain("binary");

// Assert: Check the serialized string content
resultString.Should().Contain("POST /Customers HTTP/1.1");
resultString.Should().Contain("Content-Type: application/json");
}

#region Get Operation Tests

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,15 @@ public void CrossJoin_MultipleEntitySets_ShouldIncludeAll()
}

[Fact]
public async Task CrossJoin_LessThanTwoEntitySets_ShouldThrow()
public Task CrossJoin_LessThanTwoEntitySets_ShouldThrow()
{
// Arrange
var logger = NullLogger.Instance;

// Act & Assert
var act = () => new ODataCrossJoinBuilder(["Products"], logger);
act.Should().ThrowExactly<ArgumentException>();
return Task.CompletedTask;
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void Read_InvalidDate_ReturnsDefault()
public void Read_SimpleDateFormat_ParsesCorrectly()
{
// Arrange
var json = "\"2024-01-15\"";
var json = "\"2024-01-15Z\"";

// Act
var result = JsonSerializer.Deserialize<DateTime>(json, _options);
Expand Down
4 changes: 2 additions & 2 deletions PanoramicData.OData.Client/HttpMessageContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ private async Task<byte[]> BuildContentAsync()
var sb = new StringBuilder();

// Request line: METHOD path HTTP/1.1
var requestUri = _request.RequestUri?.PathAndQuery ?? "/";
sb.Append(_request.Method.ToString());
sb.Append(' ');
var requestUri = (_request.RequestUri?.IsAbsoluteUri == true ? _request.RequestUri.PathAndQuery : _request.RequestUri?.ToString()) ?? "/";
sb.Append(requestUri);
sb.AppendLine(" HTTP/1.1");

// Host header
if (_request.RequestUri?.Host is not null)
if (_request.RequestUri is { IsAbsoluteUri: true })
{
sb.Append("Host: ");
sb.AppendLine(_request.RequestUri.Host);
Expand Down
2 changes: 0 additions & 2 deletions PanoramicData.OData.Client/ODataClient.Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ private HttpMessageContent BuildOperationContent(ODataBatchOperation operation)
}

var content = new HttpMessageContent(innerRequest);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/http");
content.Headers.TryAddWithoutValidation("Content-Transfer-Encoding", "binary");

return content;
}
Expand Down
4 changes: 4 additions & 0 deletions PanoramicData.OData.Client/PanoramicData.OData.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="PanoramicData.OData.Client.Test" />
</ItemGroup>

</Project>