using SheetMe.Core.Serialization; namespace SheetMe.Core.Tests; /// 레거시 invariant 문자열 포맷 도우미 테스트 — 실샘플 원문 형식과의 일치 검증. [TestClass] public sealed class LegacyFormatTests { /// Point/Size 파싱·생성 — "336, 1064" 왕복 [TestMethod] [DataRow("336, 1064", 336, 1064)] [DataRow("0, 22", 0, 22)] [DataRow("-5, 10", -5, 10)] public void Point_RoundTrip(string text, int x, int y) { var (px, py) = LegacyFormat.ParsePoint(text); Assert.AreEqual(x, px); Assert.AreEqual(y, py); Assert.AreEqual(text.Replace(" ", "").Insert(text.Replace(" ", "").IndexOf(',') + 1, " "), LegacyFormat.FormatPair(px, py)); } /// 폰트 파싱 — 실샘플 원문 3형태 [TestMethod] public void Font_Parse_SampleForms() { var font1 = LegacyFormat.ParseFont("굴림, 11.25pt, style=Bold"); Assert.AreEqual("굴림", font1.Family); Assert.AreEqual(11.25, font1.SizePt); Assert.IsTrue(font1.Bold); Assert.IsFalse(font1.Italic); var font2 = LegacyFormat.ParseFont("굴림, 11.25pt"); Assert.IsFalse(font2.Bold); var font3 = LegacyFormat.ParseFont("돋움, 26.25pt, style=Bold, Underline"); Assert.AreEqual("돋움", font3.Family); Assert.IsTrue(font3.Bold); Assert.IsTrue(font3.Underline); } /// 폰트 생성 — 레거시 FontConverter invariant 형식과 동일 [TestMethod] public void Font_Format_MatchesLegacy() { Assert.AreEqual("굴림, 11.25pt, style=Bold", LegacyFormat.FormatFont(new LegacyFont { Family = "굴림", SizePt = 11.25, Bold = true })); Assert.AreEqual("굴림, 9pt", LegacyFormat.FormatFont(new LegacyFont { Family = "굴림", SizePt = 9 })); Assert.AreEqual("돋움, 26.25pt, style=Bold, Underline", LegacyFormat.FormatFont(new LegacyFont { Family = "돋움", SizePt = 26.25, Bold = true, Underline = true })); } /// 폰트 왕복 — 파싱→생성 원문 유지 [TestMethod] [DataRow("굴림, 11.25pt, style=Bold")] [DataRow("굴림, 11.25pt")] [DataRow("돋움, 26.25pt, style=Bold")] public void Font_RoundTrip(string original) { Assert.AreEqual(original, LegacyFormat.FormatFont(LegacyFormat.ParseFont(original))); } /// 색 파싱 — RGB 성분/명명색/시스템색 [TestMethod] public void Color_Parse_SampleForms() { Assert.AreEqual(((byte)255, (byte)224, (byte)224, (byte)224), LegacyFormat.ParseColor("224, 224, 224")); Assert.AreEqual(((byte)255, (byte)255, (byte)255, (byte)255), LegacyFormat.ParseColor("White")); var transparent = LegacyFormat.ParseColor("Transparent"); Assert.AreEqual(0, transparent.A); // 시스템색 — 성분값은 OS 테마에 따라 다르므로 해석 성공 여부만 확인 var system = LegacyFormat.ParseColor("ControlDarkDark"); Assert.IsTrue(system.A > 0, "시스템색 해석 실패"); } /// 색 생성 — "R, G, B" invariant 형식 [TestMethod] public void Color_Format_MatchesLegacy() { Assert.AreEqual("224, 224, 224", LegacyFormat.FormatColor(255, 224, 224, 224)); Assert.AreEqual("128, 255, 0, 0", LegacyFormat.FormatColor(128, 255, 0, 0)); } }