Skip to content

Commit

Permalink
Can send and pass to Verify
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Jan 9, 2025
1 parent 0262ef0 commit 3a492cd
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 115 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Configurations>Debug;Release;Local</Configurations>
Expand All @@ -16,6 +16,7 @@
<ItemGroup>
<PackageReference Include="RhinoCommon" IncludeAssets="compile; build" PrivateAssets="all" />
<PackageReference Include="RhinoWindows" IncludeAssets="compile; build" PrivateAssets="all" />
<PackageReference Include="Verify.Xunit" />
</ItemGroup>

<ItemGroup>
Expand Down
119 changes: 106 additions & 13 deletions Connectors/Rhino/Speckle.Connectors.Rhino8/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,55 @@
"resolved": "0.9.6",
"contentHash": "HKH7tYrYYlCK1ct483hgxERAdVdMtl7gUKW9ijWXxA1UsYR4Z+TrRHYmzZ9qmpu1NnTycSrp005NYM78GDKV1w=="
},
"Verify.Xunit": {
"type": "Direct",
"requested": "[28.8.1, )",
"resolved": "28.8.1",
"contentHash": "s++6iCInd5xpv6e7cesd1/KplHaYNtXRMjOsDu+n+Z85fYeX64w+Wras+B1uAQK+Lg+0F4W5sc9jqmUkh8y8Lg==",
"dependencies": {
"Argon": "0.26.0",
"DiffEngine": "15.6.0",
"Microsoft.Bcl.AsyncInterfaces": "9.0.0",
"SimpleInfoName": "3.1.0",
"System.IO.Hashing": "9.0.0",
"System.Memory": "4.6.0",
"Verify": "28.8.1",
"xunit.abstractions": "2.0.3",
"xunit.extensibility.execution": "2.9.2"
}
},
"Argon": {
"type": "Transitive",
"resolved": "0.26.0",
"contentHash": "n7btGXdtRyprGnpLMpBs6rLScxlvPtVWwmTR8h7CtJvpZXBGhGvibEdZxRjeTZNrwf403jJ0ZPpt35Pz/NaNsw==",
"dependencies": {
"System.Collections.Immutable": "8.0.0"
}
},
"Castle.Core": {
"type": "Transitive",
"resolved": "5.1.1",
"contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g=="
},
"DiffEngine": {
"type": "Transitive",
"resolved": "15.6.0",
"contentHash": "q39O7vQknyZeKo2ipsNqoW2nH7+rntebNEOuYCbSu6rdp89om1VHOkWpERdKLYqQnIq3U20APYagcvvjoMiOlg==",
"dependencies": {
"EmptyFiles": "8.6.0",
"System.Collections.Immutable": "8.0.0",
"System.Management": "8.0.0"
}
},
"EmptyFiles": {
"type": "Transitive",
"resolved": "8.6.0",
"contentHash": "7QuYKhc8DjllLRviZPeGXfDR5LEtTtBV8loBxfrQt7tFUiPhnHkqEe710yqpSxEebys/lKSJXhPoUX3xCeqkbQ==",
"dependencies": {
"System.Collections.Immutable": "8.0.0",
"System.Memory": "4.6.0"
}
},
"GraphQL.Client": {
"type": "Transitive",
"resolved": "6.0.0",
Expand Down Expand Up @@ -87,8 +131,8 @@
},
"Microsoft.Bcl.AsyncInterfaces": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==",
"resolved": "9.0.0",
"contentHash": "owmu2Cr3IQ8yQiBleBHlGk8dSQ12oaF2e7TpzwJKEl4m84kkZJjEY1n33L67Y3zM5jPOjmmbdHjbfiL0RqcMRQ==",
"dependencies": {
"System.Threading.Tasks.Extensions": "4.5.4"
}
Expand Down Expand Up @@ -178,6 +222,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"SimpleInfoName": {
"type": "Transitive",
"resolved": "3.1.0",
"contentHash": "j+ENh86NhxrgDc6T1ueqIR2QOdDkSJY2dbTFyPN/JvIXifB4GHAunlMw/x7P6m7XaXEHr3s+SMZfKBlmnmkO6g=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -220,22 +269,53 @@
},
"System.Buffers": {
"type": "Transitive",
"resolved": "4.4.0",
"contentHash": "AwarXzzoDwX6BgrhjoJsk6tUezZEozOT5Y9QKF94Gl4JK91I4PIIBkBco9068Y9/Dra8Dkbie99kXB8+1BaYKw=="
"resolved": "4.6.0",
"contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
},
"System.CodeDom": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "WTlRjL6KWIMr/pAaq3rYqh0TJlzpouaQ/W1eelssHgtlwHAH25jXTkUphTYx9HaIIf7XA6qs/0+YhtLEQRkJ+Q=="
},
"System.Collections.Immutable": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "AurL6Y5BA1WotzlEvVaIDpqzpIPvYnnldxru8oXJU2yFxFUy3+pNXjXd1ymO+RA0rq0+590Q8gaz2l3Sr7fmqg==",
"dependencies": {
"System.Memory": "4.5.5",
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"System.ComponentModel.Annotations": {
"type": "Transitive",
"resolved": "4.5.0",
"contentHash": "UxYQ3FGUOtzJ7LfSdnYSFd7+oEv6M8NgUatatIN2HxNtDdlcvFAf+VIq4Of9cDMJEJC0aSRv/x898RYhB4Yppg=="
},
"System.IO.Hashing": {
"type": "Transitive",
"resolved": "9.0.0",
"contentHash": "seeO8icDfED/Qwl9PDFUx2Gf/7xv7dPsMnw5PnRwNZuz4EWMpy0wIVohC4MfCcTIoJgp+KUrWG4WH3NPSusQOA==",
"dependencies": {
"System.Buffers": "4.5.1",
"System.Memory": "4.5.5"
}
},
"System.Management": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "jrK22i5LRzxZCfGb+tGmke2VH7oE0DvcDlJ1HAKYU8cPmD8XnpUT0bYn2Gy98GEhGjtfbR/sxKTVb+dE770pfA==",
"dependencies": {
"System.CodeDom": "8.0.0"
}
},
"System.Memory": {
"type": "Transitive",
"resolved": "4.5.3",
"contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==",
"resolved": "4.6.0",
"contentHash": "OEkbBQoklHngJ8UD8ez2AERSk2g+/qpAaSWWCBFbpH727HxDq5ydVkuncBaKcKfwRqXGWx64dS6G1SUScMsitg==",
"dependencies": {
"System.Buffers": "4.4.0",
"System.Numerics.Vectors": "4.4.0",
"System.Runtime.CompilerServices.Unsafe": "4.5.2"
"System.Buffers": "4.6.0",
"System.Numerics.Vectors": "4.6.0",
"System.Runtime.CompilerServices.Unsafe": "6.1.0"
}
},
"System.Net.WebSockets.Client.Managed": {
Expand All @@ -249,8 +329,8 @@
},
"System.Numerics.Vectors": {
"type": "Transitive",
"resolved": "4.4.0",
"contentHash": "UiLzLW+Lw6HLed1Hcg+8jSRttrbuXv7DANVj0DkL9g6EnnzbL75EB7EWsw5uRbhxd/4YdG8li5XizGWepmG3PQ=="
"resolved": "4.6.0",
"contentHash": "t+SoieZsRuEyiw/J+qXUbolyO219tKQQI0+2/YI+Qv7YdGValA6WiuokrNKqjrTNsy5ABWU11bdKOzUdheteXg=="
},
"System.Reactive": {
"type": "Transitive",
Expand All @@ -262,8 +342,8 @@
},
"System.Runtime.CompilerServices.Unsafe": {
"type": "Transitive",
"resolved": "4.5.3",
"contentHash": "3TIsJhD1EiiT0w2CcDMN/iSSwnNnsrnbzeVHSKkaEgV85txMprmuO+Yq2AdSbeVGcg28pdNDTPK87tJhX7VFHw=="
"resolved": "6.1.0",
"contentHash": "5o/HZxx6RVqYlhKSq8/zronDkALJZUT2Vz0hx43f0gwe8mwlM0y2nYlqdBwLMzr262Bwvpikeb/yEwkAa5PADg=="
},
"System.Threading.Tasks.Extensions": {
"type": "Transitive",
Expand All @@ -273,6 +353,19 @@
"System.Runtime.CompilerServices.Unsafe": "4.5.3"
}
},
"Verify": {
"type": "Transitive",
"resolved": "28.8.1",
"contentHash": "lq4wiGgiTYOI6QR38qgY1H+SB4ejSrXReGiFFh5fjh7ZDdJtcEiVMbnReV3MF+4anw+SXmtIXWX6O3/cC4KIow==",
"dependencies": {
"Argon": "0.26.0",
"DiffEngine": "15.6.0",
"Microsoft.Bcl.AsyncInterfaces": "9.0.0",
"SimpleInfoName": "3.1.0",
"System.IO.Hashing": "9.0.0",
"System.Memory": "4.6.0"
}
},
"xunit.abstractions": {
"type": "Transitive",
"resolved": "2.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using Speckle.Converters.Common.Objects;
using Xunit;

namespace Speckle.Connectors.Rhino;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Testing;
using Speckle.HostApps;
using Xunit;

namespace Speckle.Connectors.Rhino;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Speckle.Converters.Common.Objects;
using Xunit;

namespace Speckle.Connectors.Rhino;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Speckle.Converters.Common;
using Speckle.Converters.Rhino;
using Xunit;

namespace Speckle.Connectors.Rhino;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Rhino;
using Speckle.Connectors.DUI.Bindings;
using Speckle.HostApps;
using Xunit;

namespace Speckle.Connectors.Rhino;

Expand Down
51 changes: 11 additions & 40 deletions Connectors/Rhino/Speckle.Connectors.RhinoShared/Tests/SendTests.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
using FluentAssertions;
using System.IO;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using Rhino;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Exceptions;
using Speckle.Connectors.DUI.Models.Card;
using Speckle.Connectors.DUI.Testing;
using Speckle.Connectors.Rhino.Filters;
using Speckle.HostApps;
using Speckle.Sdk.Api;
using Speckle.Sdk.Models;
using Speckle.Sdk.Serialisation.V2.Send;
using Speckle.Sdk.Transports;
using Xunit;
using Speckle.Sdk.SQLite;

namespace Speckle.Connectors.Rhino;

Expand Down Expand Up @@ -66,45 +62,20 @@ public async Task Test_Send_Current()
ModelId = "ModelId",
});

var testOperations = (TestOperations)serviceProvider.GetRequiredService<IOperations>();
testOperations.WrappedOperations = new TestSender();

var testFactory = (TestSqLiteJsonCacheManagerFactory)serviceProvider.GetRequiredService<ISqLiteJsonCacheManagerFactory>();
var fileName = Path.GetTempFileName();
testFactory.Initialize(fileName);
var send = serviceProvider.GetBinding<ISendBinding>();

await send.Send(MODEL_CARD_ID);
}

private sealed class TestSender : IOperations
{
public Task<Base> Receive2(Uri url, string streamId, string objectId, string? authorizationToken = null,
IProgress<ProgressArgs>? onProgressAction = null, CancellationToken cancellationToken = new CancellationToken()) =>
throw new NotImplementedException();
var sqLiteJsonCacheManager = testFactory.CreateFromStream(string.Empty);
var all = sqLiteJsonCacheManager.GetAllObjects();
await Verify(all);

public Task<Base> Receive(string objectId, ITransport? remoteTransport = null, ITransport? localTransport = null,
IProgress<ProgressArgs>? onProgressAction = null, CancellationToken cancellationToken = new CancellationToken()) =>
throw new NotImplementedException();

public Task<SerializeProcessResults> Send2(Uri url, string streamId, string? authorizationToken, Base value,
IProgress<ProgressArgs>? onProgressAction = null,
CancellationToken cancellationToken = new())
if (File.Exists(fileName))
{
return Task.FromResult(new SerializeProcessResults());
File.Delete(fileName);
}

public Task<(string rootObjId, IReadOnlyDictionary<string, ObjectReference> convertedReferences)> Send(Base value, IServerTransport transport, bool useDefaultCache, IProgress<ProgressArgs>? onProgressAction = null,
CancellationToken cancellationToken = new CancellationToken()) =>
throw new NotImplementedException();

public Task<(string rootObjId, IReadOnlyDictionary<string, ObjectReference> convertedReferences)> Send(Base value, ITransport transport, bool useDefaultCache, IProgress<ProgressArgs>? onProgressAction = null,
CancellationToken cancellationToken = new CancellationToken()) =>
throw new NotImplementedException();

public Task<(string rootObjId, IReadOnlyDictionary<string, ObjectReference> convertedReferences)> Send(Base value, IReadOnlyCollection<ITransport> transports, IProgress<ProgressArgs>? onProgressAction = null,
CancellationToken cancellationToken = new CancellationToken()) =>
throw new NotImplementedException();

public string Serialize(Base value, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException();

public Task<Base> DeserializeAsync(string value, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException();
}
}
40 changes: 30 additions & 10 deletions DUI3/Speckle.Connectors.DUI/Bindings/ConfigBinding.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
using System.Runtime.Serialization;
using Speckle.Connectors.DUI.Bridge;
using Speckle.Connectors.DUI.Utils;
using Speckle.InterfaceGenerator;
using Speckle.Sdk;
using Speckle.Sdk.SQLite;

namespace Speckle.Connectors.DUI.Bindings;

[GenerateAutoInterface]
public class ConfigStorage : IConfigStorage
{

private readonly ISqLiteJsonCacheManager _jsonCacheManager;
private readonly ISpeckleApplication _speckleApplication;

public ConfigStorage(ISqLiteJsonCacheManagerFactory sqLiteJsonCacheManagerFactory, ISpeckleApplication speckleApplication)
{
_speckleApplication = speckleApplication;
_jsonCacheManager = sqLiteJsonCacheManagerFactory.CreateForUser("DUI3Config"); // POC: maybe inject? (if we ever want to use a different storage for configs later down the line)
}

public string? GetConfig() => _jsonCacheManager.GetObject(_speckleApplication.HostApplication);
public void UpdateConfig(string config) => _jsonCacheManager.UpdateObject(_speckleApplication.HostApplication, config);


public string? GetAccounts() => _jsonCacheManager.GetObject("accounts");
public void UpdateAccounts(string config) => _jsonCacheManager.UpdateObject("accounts", config);
}

/// <summary>
/// POC: Simple config binding, as it was driving Dim nuts he couldn't swap to a dark theme.
/// How does it store configs? In a sqlite db called 'DUI3Config', we create a row for each host application:
Expand All @@ -17,20 +39,18 @@ public class ConfigBinding : IBinding
{
public string Name => "configBinding";
public IBrowserBridge Parent { get; }
private readonly ISqLiteJsonCacheManager _jsonCacheManager;
private readonly ISpeckleApplication _speckleApplication;

private readonly IConfigStorage _configStorage;
private readonly IJsonSerializer _serializer;

public ConfigBinding(
IJsonSerializer serializer,
ISpeckleApplication speckleApplication,
IBrowserBridge bridge,
ISqLiteJsonCacheManagerFactory sqLiteJsonCacheManagerFactory
IConfigStorage configStorage
)
{
Parent = bridge;
_jsonCacheManager = sqLiteJsonCacheManagerFactory.CreateForUser("DUI3Config"); // POC: maybe inject? (if we ever want to use a different storage for configs later down the line)
_speckleApplication = speckleApplication;
_configStorage = configStorage;
_serializer = serializer;
}

Expand All @@ -47,7 +67,7 @@ public bool GetIsDevMode()

public ConnectorConfig GetConfig()
{
var rawConfig = _jsonCacheManager.GetObject(_speckleApplication.HostApplication);
var rawConfig = _configStorage.GetConfig();
if (rawConfig is null)
{
return SeedConfig();
Expand Down Expand Up @@ -79,18 +99,18 @@ private ConnectorConfig SeedConfig()
public void UpdateConfig(ConnectorConfig config)
{
var str = _serializer.Serialize(config);
_jsonCacheManager.UpdateObject(_speckleApplication.HostApplication, str);
_configStorage.UpdateConfig( str);
}

public void SetUserSelectedAccountId(string userSelectedAccountId)
{
var str = _serializer.Serialize(new AccountsConfig() { UserSelectedAccountId = userSelectedAccountId });
_jsonCacheManager.UpdateObject("accounts", str);
_configStorage.UpdateAccounts(str);
}

public AccountsConfig? GetUserSelectedAccountId()
{
var rawConfig = _jsonCacheManager.GetObject("accounts");
var rawConfig = _configStorage.GetAccounts();
if (rawConfig is null)
{
return null;
Expand Down
Loading

0 comments on commit 3a492cd

Please sign in to comment.