fix(m2): fix repository tag model issue
This commit is contained in:
1 parent
01367edaa9
commit
e2bb0298b1
5 files changed
+150
-15
No files matched your search
@@ -0,0 +1,72 @@
|
||||
using YKanBan.Models;
|
||||
|
||||
namespace YKanBan.Tests.Models;
|
||||
|
||||
/// <summary>Tests for the RGB color value type and its #RRGGBB text conversions.</summary>
|
||||
[TestClass]
|
||||
public class RgbColorTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void ParseExtractsComponents()
|
||||
{
|
||||
RgbColor color = RgbColor.Parse("#ff0a00");
|
||||
Assert.AreEqual(new RgbColor(0xFF, 0x0A, 0x00), color);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ParseAcceptsUppercaseAndMixedCaseHex()
|
||||
{
|
||||
Assert.AreEqual(new RgbColor(0xAB, 0xCD, 0xEF), RgbColor.Parse("#ABCDEF"));
|
||||
Assert.AreEqual(new RgbColor(0xAB, 0xCD, 0xEF), RgbColor.Parse("#aBcDeF"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("ff0000")]
|
||||
[DataRow("#ff000")]
|
||||
[DataRow("#ff00000")]
|
||||
[DataRow("#gg0000")]
|
||||
[DataRow("#ff 000")]
|
||||
[DataRow(" #ff0000")]
|
||||
[DataRow("#ff0000 ")]
|
||||
[DataRow("#")]
|
||||
[DataRow("")]
|
||||
public void TryParseRejectsMalformedText(string text)
|
||||
{
|
||||
Assert.IsFalse(RgbColor.TryParse(text, out _));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TryParseRejectsNull()
|
||||
{
|
||||
Assert.IsFalse(RgbColor.TryParse(null, out _));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ParseThrowsFormatExceptionForMalformedText()
|
||||
{
|
||||
Assert.ThrowsExactly<FormatException>(() => RgbColor.Parse("red"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ToStringProducesCanonicalLowercaseForm()
|
||||
{
|
||||
Assert.AreEqual("#ee0a0a", new RgbColor(0xEE, 0x0A, 0x0A).ToString());
|
||||
|
||||
// Uppercase input normalizes to the canonical lowercase output.
|
||||
Assert.AreEqual("#ee0a0a", RgbColor.Parse("#EE0A0A").ToString());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EqualityComparesComponents()
|
||||
{
|
||||
Assert.AreEqual(RgbColor.Parse("#ff0000"), RgbColor.Parse("#FF0000"));
|
||||
Assert.AreNotEqual(RgbColor.Parse("#ff0000"), RgbColor.Parse("#ff0001"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TextRoundTripPreservesColor()
|
||||
{
|
||||
RgbColor original = new(0x12, 0x34, 0x56);
|
||||
Assert.AreEqual(original, RgbColor.Parse(original.ToString()));
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public class WorkspaceRepositoryTests
|
||||
using var fixture = new RepositoryFixture();
|
||||
fixture.Clock = 2000;
|
||||
|
||||
TagModel result = fixture.Repository.UpdateTag(fixture.BugTagId, "bug", "#ff0000", "");
|
||||
TagModel result = fixture.Repository.UpdateTag(fixture.BugTagId, "bug", RgbColor.Parse("#ff0000"), "");
|
||||
|
||||
Assert.AreEqual("bug", result.Name);
|
||||
Assert.AreEqual(0, fixture.AppDb.GetWorkspaces().Count);
|
||||
@@ -247,10 +247,10 @@ public class WorkspaceRepositoryTests
|
||||
using var fixture = new RepositoryFixture();
|
||||
fixture.Clock = 3000;
|
||||
|
||||
TagModel updated = fixture.Repository.UpdateTag(fixture.BugTagId, "defect", "#ee0a0a", "desc");
|
||||
TagModel updated = fixture.Repository.UpdateTag(fixture.BugTagId, "defect", RgbColor.Parse("#ee0a0a"), "desc");
|
||||
|
||||
Assert.AreEqual("defect", updated.Name);
|
||||
Assert.AreEqual("#ee0a0a", updated.Color);
|
||||
Assert.AreEqual(new RgbColor(0xEE, 0x0A, 0x0A), updated.Color);
|
||||
Assert.AreEqual("desc", updated.Description);
|
||||
Assert.AreEqual(3000L, fixture.LastEditedAt);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user