[#67] Add unit tests
All checks were successful
DCO / DCO (pull_request) Successful in 21s
lint-build / dotnet8.0 (pull_request) Successful in 43s
lint-build / dotnet8.0 (push) Successful in 42s

Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
Pavel Gross 2025-04-23 00:30:34 +03:00
parent 20586d8ada
commit eebba7665b
13 changed files with 1094 additions and 233 deletions

View file

@ -41,6 +41,8 @@ public class ObjectMocker(string key) : ObjectServiceBase(key)
public Collection<ByteString> RangeHashResponses { get; } = [];
public Action? Callback;
public override Mock<ObjectService.ObjectServiceClient> GetMock()
{
var mock = new Mock<ObjectService.ObjectServiceClient>();
@ -165,9 +167,14 @@ public class ObjectMocker(string key) : ObjectServiceBase(key)
It.IsAny<CancellationToken>()))
.Returns((PutSingleRequest r, Metadata m, DateTime? dt, CancellationToken ct) =>
{
Callback?.Invoke();
Verifier.CheckRequest(r);
PutSingleRequests.Add(r);
var req = r.Clone();
// Clone method does not clone the payload but keeps a reference
req.Body.Object.Payload = ByteString.CopyFrom(r.Body.Object.Payload.ToByteArray());
PutSingleRequests.Add(req);
return new AsyncUnaryCall<PutSingleResponse>(
Task.FromResult(putSingleResponse),