Backend/e-suite.Database.Core/e-suite.Database.Core.UnitTests/GeneralIdExtensionsUnitTest.cs
2026-01-20 21:50:10 +00:00

105 lines
2.3 KiB
C#

using e_suite.Database.Core.Extensions;
using e_suite.Database.Core.Models;
using eSuite.Core.Miscellaneous;
using NUnit.Framework;
namespace e_suite.Database.Core.UnitTests;
[TestFixture]
public class GeneralIdExtensionsUnitTest
{
private class TestClass : IGeneralId
{
public long Id { get; set; }
public Guid Guid { get; set; }
}
private TestClass testClass { get; set; } = null!;
[SetUp]
public void Setup()
{
testClass = new TestClass
{
Guid = new Guid("a6576bfa-364e-4453-9f58-0448f0045cc3"),
Id = 2356234
};
}
[Test]
public void IsMatch_WhenIdAndGuidNull_ReturnsFalse()
{
//Arrange
var comparitor = new GeneralIdRef();
//Act
var actualResult = testClass.IsMatch(comparitor);
//Assert
Assert.That(actualResult, Is.False);
}
[Test]
public void IsMatch_WhenGuidDoesNotMatch_ReturnsFalse()
{
//Arrange
var comparitor = new GeneralIdRef
{
Guid = new Guid("5a05a440-9a55-4e80-91b4-314e1b287182")
};
//Act
var actualResult = testClass.IsMatch(comparitor);
//Assert
Assert.That(actualResult, Is.False);
}
[Test]
public void IsMatch_WhenIdDoesNotMatch_ReturnsFalse()
{
//Arrange
var comparitor = new GeneralIdRef
{
Id = 9328475
};
//Act
var actualResult = testClass.IsMatch(comparitor);
//Assert
Assert.That(actualResult, Is.False);
}
[Test]
public void IsMatch_WhenGuidMatches_ReturnsTrue()
{
//Arrange
var comparitor = new GeneralIdRef
{
Guid = testClass.Guid
};
//Act
var actualResult = testClass.IsMatch(comparitor);
//Assert
Assert.That(actualResult, Is.True);
}
[Test]
public void IsMatch_WhenIdMatches_ReturnsTrue()
{
//Arrange
var comparitor = new GeneralIdRef
{
Id = testClass.Id
};
//Act
var actualResult = testClass.IsMatch(comparitor);
//Assert
Assert.That(actualResult, Is.True);
}
}