Phase 14 complete — v0.4 Robustness milestone closed:
- HardwareTestHelper.GetIpOrSkip: Assert.Ignore when HEIDENHAIN/SIEMENS/MITSUBISHI_IP not set (ISS-007)
- Hardware_ConnectAsync_RealMachine [Category("Hardware")] added to all 3 integration test files
- LicenseFileTests: 4 tests covering empty, whitespace, valid base64, nonexistent path
- Validate_EmptyFingerprint_ReturnsFalse: confirms validator safe against empty input (ISS-008 scaffold)
- NcProgramManager.Tests.csproj: <Compile> entries for 2 new files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
using System.IO;
|
|
using NUnit.Framework;
|
|
using NcProgramManager.Licensing;
|
|
|
|
namespace NcProgramManager.Tests.Unit
|
|
{
|
|
[TestFixture]
|
|
internal class LicenseFileTests
|
|
{
|
|
private string _tempPath;
|
|
|
|
[SetUp]
|
|
public void SetUp()
|
|
{
|
|
_tempPath = Path.GetTempFileName();
|
|
}
|
|
|
|
[TearDown]
|
|
public void TearDown()
|
|
{
|
|
if (File.Exists(_tempPath))
|
|
File.Delete(_tempPath);
|
|
}
|
|
|
|
[Test]
|
|
public void TryRead_EmptyFile_ReturnsFalse()
|
|
{
|
|
File.WriteAllText(_tempPath, string.Empty);
|
|
bool result = LicenseFile.TryRead(_tempPath, out string base64);
|
|
Assert.IsFalse(result);
|
|
Assert.IsNull(base64);
|
|
}
|
|
|
|
[Test]
|
|
public void TryRead_WhitespaceOnly_ReturnsFalse()
|
|
{
|
|
File.WriteAllText(_tempPath, " \n\r\n ");
|
|
bool result = LicenseFile.TryRead(_tempPath, out string base64);
|
|
Assert.IsFalse(result);
|
|
Assert.IsNull(base64);
|
|
}
|
|
|
|
[Test]
|
|
public void TryRead_ValidBase64Content_ReturnsTrueWithTrimmedValue()
|
|
{
|
|
string expected = "SGVsbG8gV29ybGQ=";
|
|
File.WriteAllText(_tempPath, expected + "\n");
|
|
bool result = LicenseFile.TryRead(_tempPath, out string base64);
|
|
Assert.IsTrue(result);
|
|
Assert.AreEqual(expected, base64);
|
|
}
|
|
|
|
[Test]
|
|
public void TryRead_NonExistentPath_ReturnsFalse()
|
|
{
|
|
bool result = LicenseFile.TryRead(_tempPath + ".notexist", out string base64);
|
|
Assert.IsFalse(result);
|
|
Assert.IsNull(base64);
|
|
}
|
|
}
|
|
}
|