using System.Collections.Concurrent; using Shouldly; using Speckle.Newtonsoft.Json.Linq; using Speckle.Sdk.Common; using Speckle.Sdk.Dependencies.Serialization; using Speckle.Sdk.Serialisation.V2; using Speckle.Sdk.Transports; namespace Speckle.Sdk.Serialization.Tests; public class DummySendServerObjectManager(ConcurrentDictionary savedObjects) : IServerObjectManager { public IAsyncEnumerable<(string, string)> DownloadObjects( IReadOnlyList objectIds, IProgress? progress, CancellationToken cancellationToken ) => throw new NotImplementedException(); public Task DownloadSingleObject( string objectId, IProgress? progress, CancellationToken cancellationToken ) => throw new NotImplementedException(); public Task> HasObjects(IReadOnlyList objectIds, CancellationToken cancellationToken) { return Task.FromResult(objectIds.ToDictionary(x => x, x => false)); } public Task UploadObjects( IReadOnlyList objects, bool compressPayloads, IProgress? progress, CancellationToken cancellationToken ) { foreach (var obj in objects) { obj.Id.ShouldBe(JObject.Parse(obj.Json)["id"].NotNull().Value()); if (savedObjects.TryGetValue(obj.Id, out var j)) { j.ShouldBe(obj.Json); } else { savedObjects.TryAdd(obj.Id, obj.Json); } } return Task.CompletedTask; } }