Files
ps.ipam/classlib.tests/Models/TagTests.cs

64 lines
1.6 KiB
C#

namespace PS.IPAM.Tests.Models;
using FluentAssertions;
using PS.IPAM;
using Xunit;
public class TagTests
{
[Fact]
public void Constructor_SetsAllProperties()
{
// Arrange
var id = 1;
var type = "Used";
var showTag = true;
var bgColor = "#5cb85c";
var fgColor = "#ffffff";
var compress = "Yes";
var locked = "No";
var updateTag = true;
// Act
var tag = new Tag(id, type, showTag, bgColor, fgColor, compress, locked, updateTag);
// Assert
tag.Id.Should().Be(id);
tag.Type.Should().Be(type);
tag.ShowTag.Should().Be(showTag);
tag.BackgroundColor.Should().Be(bgColor);
tag.ForegroundColor.Should().Be(fgColor);
tag.Compress.Should().Be(compress);
tag.Locked.Should().Be(locked);
tag.UpdateTag.Should().Be(updateTag);
}
[Theory]
[InlineData("Used")]
[InlineData("Available")]
[InlineData("Reserved")]
[InlineData("DHCP")]
public void ToString_ReturnsTagType(string tagType)
{
// Arrange
var tag = new Tag(1, tagType, false, "", "", "No", "No", false);
// Act
var result = tag.ToString();
// Assert
result.Should().Be(tagType);
}
[Fact]
public void Record_Equality_WorksCorrectly()
{
// Arrange
var tag1 = new Tag(1, "Used", true, "#fff", "#000", "Yes", "No", false);
var tag2 = new Tag(1, "Used", true, "#fff", "#000", "Yes", "No", false);
// Assert
tag1.Should().Be(tag2);
}
}