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); } } }