Remove Jenkinsfile and add unit tests for various models including Address, Domain, Nameserver, Section, Session, Subnetwork, Tag, Vlan, and Vrf. Introduce mock classes for HTTP requests and cmdlet testing.
This commit is contained in:
60
classlib.tests/Models/VrfTests.cs
Normal file
60
classlib.tests/Models/VrfTests.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
namespace PS.IPAM.Tests.Models;
|
||||
|
||||
using FluentAssertions;
|
||||
using PS.IPAM;
|
||||
using Xunit;
|
||||
|
||||
public class VrfTests
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_SetsAllProperties()
|
||||
{
|
||||
// Arrange
|
||||
var id = 1;
|
||||
var name = "VRF_PROD";
|
||||
var rd = "65000:100";
|
||||
var description = "Production VRF";
|
||||
var sections = "1;2;3";
|
||||
var editDate = new DateTime(2026, 1, 10);
|
||||
var customFields = new Dictionary<string, object> { { "custom_tenant", "CustomerA" } };
|
||||
|
||||
// Act
|
||||
var vrf = new Vrf(id, name, rd, description, sections, editDate, customFields);
|
||||
|
||||
// Assert
|
||||
vrf.Id.Should().Be(id);
|
||||
vrf.Name.Should().Be(name);
|
||||
vrf.RouteDistinguisher.Should().Be(rd);
|
||||
vrf.Description.Should().Be(description);
|
||||
vrf.Sections.Should().Be(sections);
|
||||
vrf.EditDate.Should().Be(editDate);
|
||||
vrf.ExtendedData.Should().BeEquivalentTo(customFields);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("VRF_DEFAULT")]
|
||||
[InlineData("Production_VRF")]
|
||||
[InlineData("CUSTOMER_A")]
|
||||
public void ToString_ReturnsVrfName(string vrfName)
|
||||
{
|
||||
// Arrange
|
||||
var vrf = new Vrf(1, vrfName, "65000:1", "", "", null, null);
|
||||
|
||||
// Act
|
||||
var result = vrf.ToString();
|
||||
|
||||
// Assert
|
||||
result.Should().Be(vrfName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WithNullOptionalFields_SetsNullValues()
|
||||
{
|
||||
// Act
|
||||
var vrf = new Vrf(1, "Test", "65000:1", "", "", null, null);
|
||||
|
||||
// Assert
|
||||
vrf.EditDate.Should().BeNull();
|
||||
vrf.ExtendedData.Should().BeNull();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user