Skip to content

Commit

Permalink
- reverts change on multipart request adapter so consumer doesn't hav…
Browse files Browse the repository at this point in the history
…e to set it
  • Loading branch information
baywet committed Jul 21, 2023
1 parent 4f6672a commit fc856b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ public void SetsBoundaryOnMultipartBody()
serializationWriterFactoryMock.Setup(x => x.GetSerializationWriter(It.IsAny<string>())).Returns(serializationWriterMock.Object);
requestAdapterMock.SetupGet(x => x.SerializationWriterFactory).Returns(serializationWriterFactoryMock.Object);
// Given
var multipartBody = new MultipartBody(requestAdapterMock.Object);
var multipartBody = new MultipartBody
{
RequestAdapter = requestAdapterMock.Object
};

// When
testRequest.SetContentFromParsable(requestAdapterMock.Object, "multipart/form-data", multipartBody);
Expand Down
11 changes: 3 additions & 8 deletions src/MultipartBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@ public class MultipartBody : IParsable
/// </summary>
public string Boundary => _boundary.Value;
/// <summary>
/// Creates a new instance of <see cref="MultipartBody"/> with the specified request adapter.
/// The request adapter to use for serialization.
/// </summary>
/// <param name="requestAdapter">The request adapter to use.</param>
public MultipartBody(IRequestAdapter requestAdapter)
{
RequestAdapter = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
}
private readonly IRequestAdapter RequestAdapter;
public IRequestAdapter? RequestAdapter { get; set; }
/// <summary>
/// Adds or replaces a part to the multipart body.
/// </summary>
Expand Down Expand Up @@ -98,7 +93,7 @@ public void Serialize(ISerializationWriter writer)
{
throw new ArgumentNullException(nameof(writer));
}
if(RequestAdapter.SerializationWriterFactory == null)
if(RequestAdapter?.SerializationWriterFactory == null)
{
throw new InvalidOperationException(nameof(RequestAdapter.SerializationWriterFactory));
}
Expand Down

0 comments on commit fc856b4

Please sign in to comment.