Skip to content
Merged
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
2 changes: 1 addition & 1 deletion csharp/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<!-- Fallback version for any build that does NOT pass /p:Version (local dev, source/project
references). Keep this >= every published release and every consumer's compiled reference
so roll-forward always succeeds. Bump on each release alongside the git tag. -->
<Version Condition="'$(Version)' == ''">2.11.1</Version>
<Version Condition="'$(Version)' == ''">2.14.0</Version>

<!-- AssemblyVersion / FileVersion track the package Version (strip any prerelease suffix such
as -preview1; AssemblyVersion must be purely numeric). The CLR pads a 3-part value to
Expand Down
45 changes: 45 additions & 0 deletions csharp/RocketWelder.SDK.Devices.Welding.Tests/Doubles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using ModelingEvolution.Drawing;
using ModelingEvolution.Signals;
using RocketWelder.SDK.Abstractions;

namespace RocketWelder.SDK.Devices.Welding.Tests;

/// <summary>
/// Implements <see cref="IWeldingMachine"/> without overriding any of the wire-inch surface, so
/// <c>CanWireInch</c>/<c>WireInchSignal</c>/<c>WireInch</c>/<c>WireInchOn</c>/<c>WireInchOff</c>
/// resolve to the interface's default implementations (design.md "SDK — IWeldingMachine delta").
/// </summary>
internal sealed class UnsupportedWeldingMachine : IWeldingMachine
{
private static WritableSignal<T> Signal<T>(string name) =>
new(new SignalMetadata(name, new Uri($"signal://test/{name}"), null, null));

public DeviceId Id { get; } = new("test-welder", Guid.Empty);
public bool IsConnected { get; init; }

public ISignal<Amps<float>> CurrentSignal { get; } = Signal<Amps<float>>("current");
public ISignal<Amps<float>> TargetCurrentSignal { get; } = Signal<Amps<float>>("target-current");
public ISignal<Speed<float>> WireFeedSpeedSignal { get; } = Signal<Speed<float>>("wire-feed-speed");
public ISignal<Volts<float>> WeldingVoltageSignal { get; } = Signal<Volts<float>>("welding-voltage");

public WritableSignal<WeldingMode> ModeSignal { get; } = Signal<WeldingMode>("mode");
public WeldingMode Mode { get; set; }

public WritableSignal<bool> WeldingStartSignal { get; } = Signal<bool>("welding-start");
public bool WeldingStart { get; set; }

public WritableSignal<bool> GasSignal { get; } = Signal<bool>("gas");
public bool Gas { get; set; }

public WritableSignal<int> JobNumberSignal { get; } = Signal<int>("job-number");
public int JobNumber { get; set; }

public ValueTask ArcOn() => throw new NotSupportedException();
public ValueTask ArcOff() => ValueTask.CompletedTask;
public ValueTask GasOn() => throw new NotSupportedException();
public ValueTask GasOff() => ValueTask.CompletedTask;

public void Dispose()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="FluentAssertions" Version="6.12.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\RocketWelder.SDK.Devices.Welding\RocketWelder.SDK.Devices.Welding.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using FluentAssertions;

namespace RocketWelder.SDK.Devices.Welding.Tests;

/// <summary>
/// design.md "SDK — IWeldingMachine delta" / test-scenarios.md U-01..U-03: the wire-inch surface's
/// default interface members, exercised through an implementation that overrides none of them.
/// </summary>
public class WireInchDefaultsTests
{
[Fact]
public void CanWireInch_Should_Be_False_On_An_Unsupported_Welder()
{
// Arrange
IWeldingMachine welder = new UnsupportedWeldingMachine();

// Act & Assert
welder.CanWireInch.Should().BeFalse();
}

[Fact]
public async Task WireInchOn_Should_Throw_NotSupportedException_On_An_Unsupported_Welder()
{
// Arrange
IWeldingMachine welder = new UnsupportedWeldingMachine();

// Act
var act = () => welder.WireInchOn().AsTask();

// Assert
await act.Should().ThrowAsync<NotSupportedException>();
}

[Fact]
public async Task WireInchOff_Should_Complete_Without_Throwing_When_Unsupported_And_Disconnected()
{
// Arrange
IWeldingMachine welder = new UnsupportedWeldingMachine { IsConnected = false };

// Act
var act = () => welder.WireInchOff().AsTask();

// Assert
await act.Should().NotThrowAsync();
}
}
15 changes: 15 additions & 0 deletions csharp/RocketWelder.SDK.Devices.Welding/IWeldingMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,19 @@ public interface IWeldingMachine : IDevice

/// <summary>Close the shielding-gas valve. Returns when the hardware has acknowledged the command.</summary>
ValueTask GasOff();

/// <summary>Whether this welder can feed wire out of the torch. UI gate; defaults to unsupported.</summary>
bool CanWireInch => false;

/// <summary>Wire-inch held level, shaped like <see cref="GasSignal"/>. Defaults to unsupported.</summary>
WritableSignal<bool> WireInchSignal => throw new NotSupportedException();

/// <summary>Plain ergonomic surface. Defaults to unsupported (false / throws); an override forwards to <see cref="WireInchSignal"/>.</summary>
bool WireInch { get => false; set => throw new NotSupportedException(); }

/// <summary>Engage wire feed. Throws <see cref="NotSupportedException"/> when unsupported.</summary>
ValueTask WireInchOn() => throw new NotSupportedException();

/// <summary>Disengage wire feed. Idempotent and never throws, connected or not.</summary>
ValueTask WireInchOff() => ValueTask.CompletedTask;
}
14 changes: 14 additions & 0 deletions csharp/RocketWelder.SDK.sln
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RocketWelder.SDK.Devices.Mo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RocketWelder.SDK.Devices.Motion.Tests", "RocketWelder.SDK.Devices.Motion.Tests\RocketWelder.SDK.Devices.Motion.Tests.csproj", "{30189920-72B0-41AE-9B2A-E49C7A7071DB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RocketWelder.SDK.Devices.Welding.Tests", "RocketWelder.SDK.Devices.Welding.Tests\RocketWelder.SDK.Devices.Welding.Tests.csproj", "{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -514,6 +516,18 @@ Global
{30189920-72B0-41AE-9B2A-E49C7A7071DB}.Release|x64.Build.0 = Release|Any CPU
{30189920-72B0-41AE-9B2A-E49C7A7071DB}.Release|x86.ActiveCfg = Release|Any CPU
{30189920-72B0-41AE-9B2A-E49C7A7071DB}.Release|x86.Build.0 = Release|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Debug|x64.ActiveCfg = Debug|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Debug|x64.Build.0 = Debug|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Debug|x86.ActiveCfg = Debug|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Debug|x86.Build.0 = Debug|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Release|Any CPU.Build.0 = Release|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Release|x64.ActiveCfg = Release|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Release|x64.Build.0 = Release|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Release|x86.ActiveCfg = Release|Any CPU
{5F8278F0-C070-4CCB-83FD-D9AB4F3DE798}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading