mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-04 05:51:34 -05:00
Ahead of the new laser schedule, three ways a post could silently cut with the wrong process, and one way its settings silently reset: - Cincinnati CL wrote no G89 when no cut library matched the nest's material, thickness and gas (or no etch library for etch features), so the controller cut with whatever library it loaded last. It now refuses, unless the new "Require libraries" setting is turned off. - Cincinnati CL declared G20/G21 from its own setting without comparing the nest's units, so a metric nest posted 25.4x too large. It now refuses a mismatch. - CI Fiber posted any material missing from its table as the default code (MSN), so stainless or aluminum ran with mild-steel technology. A named, unmapped material is now refused; the default code covers only nests with no material. - Posts saved their settings beside their DLL, inside the install folder a Velopack update replaces, so every update reset them to the shipped defaults. Saves now go to %APPDATA%\OpenNest\Posts and the shipped JSON only seeds them; constructing a post no longer writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using OpenNest.Posts.Cincinnati;
|
|
using OpenNest.Posts.CincinnatiCIFiber;
|
|
using Xunit;
|
|
|
|
namespace OpenNest.Tests.PostSettings;
|
|
|
|
/// <summary>
|
|
/// An update replaces the install folder, so a post's edited settings must live outside it:
|
|
/// saves go to the user's settings directory and the shipped JSON only seeds them.
|
|
/// </summary>
|
|
[Collection(Collection)]
|
|
public class PostSettingsFileTests : IDisposable
|
|
{
|
|
/// <summary>Tests that set <see cref="PostSettingsFile.DirectoryOverride"/> share it, so they never run together.</summary>
|
|
public const string Collection = "PostSettingsFile";
|
|
|
|
private readonly string directory =
|
|
Path.Combine(Path.GetTempPath(), "opennest-post-settings-" + Guid.NewGuid());
|
|
|
|
public PostSettingsFileTests() => PostSettingsFile.DirectoryOverride = directory;
|
|
|
|
public void Dispose()
|
|
{
|
|
PostSettingsFile.DirectoryOverride = null;
|
|
if (Directory.Exists(directory))
|
|
Directory.Delete(directory, recursive: true);
|
|
}
|
|
|
|
[Fact]
|
|
public void Save_WritesTheUserCopy_AndLeavesTheShippedDefaultsUntouched()
|
|
{
|
|
var assembly = typeof(CincinnatiPostProcessor).Assembly;
|
|
var shipped = PostSettingsFile.ShippedPathFor(assembly);
|
|
var shippedBefore = File.ReadAllText(shipped);
|
|
|
|
var post = new CincinnatiPostProcessor();
|
|
Assert.NotEmpty(post.Config.MaterialLibraries);
|
|
post.Config.ConfigurationName = "EDITED";
|
|
post.SaveConfig();
|
|
|
|
Assert.Equal(shippedBefore, File.ReadAllText(shipped));
|
|
Assert.StartsWith(directory, PostSettingsFile.PathFor(assembly));
|
|
Assert.Equal("EDITED", new CincinnatiPostProcessor().Config.ConfigurationName);
|
|
Assert.False(File.Exists(PostSettingsFile.PathFor(assembly) + ".tmp"));
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructing_WithNoSavedCopy_ReadsTheShippedDefaultsWithoutWriting()
|
|
{
|
|
var post = new CIFiberPostProcessor();
|
|
|
|
Assert.Contains("Carbon Steel", post.Config.MaterialCodes.Keys);
|
|
Assert.False(Directory.Exists(directory));
|
|
}
|
|
}
|