using e_suite.Database.Core.Extensions; using e_suite.Database.Core.Models; using NUnit.Framework; namespace e_suite.Database.Core.UnitTests; [TestFixture] public class GeneralIdRefExtensionsUnitTests { private class TestClass : IGeneralId { public long Id { get; set; } public Guid Guid { get; set; } } [Test] public void ToGeneralIdRef_Converting_AssignsCorrectValues() { //Arrange var testClass = new TestClass { Id = 100, Guid = new Guid("{3795F04F-8536-4C56-9FF6-D46649998253}") }; //Act var actualResult = testClass.ToGeneralIdRef(); //Assert Assert.That(actualResult!.Id, Is.EqualTo(testClass.Id)); Assert.That(actualResult!.Guid, Is.EqualTo(testClass.Guid)); } [Test] public void ToGeneralIdRef_WhenNull_AssignsNull() { //Arrange TestClass testClass = null!; //Act var actualResult = testClass.ToGeneralIdRef(); //Assert Assert.That(actualResult, Is.Null); } [Test] public void ToGeneralIfRefs_ConvertingList_AssignsCorrectValues() { //Arrange var testList = new List { new TestClass { Id = 100, Guid = new Guid("C2E5764F-086B-496A-AB8C-CCBCF37BE8A5") }, new TestClass { Id = 101, Guid = new Guid("6EB942AD-0118-4941-BEDC-6E4B8FA79579") }, new TestClass { Id = 102, Guid = new Guid("3c8348e4-96ff-44f6-b421-64fd176b1bfb") } }; //Act var actualResult = testList.ToGeneralIfRefs().ToList(); //Assert Assert.That(actualResult.Count, Is.EqualTo(testList.Count)); Assert.That(actualResult[0].Id, Is.EqualTo(testList[0].Id)); Assert.That(actualResult[0].Guid, Is.EqualTo(testList[0].Guid)); Assert.That(actualResult[1].Id, Is.EqualTo(testList[1].Id)); Assert.That(actualResult[1].Guid, Is.EqualTo(testList[1].Guid)); Assert.That(actualResult[2].Id, Is.EqualTo(testList[2].Id)); Assert.That(actualResult[2].Guid, Is.EqualTo(testList[2].Guid)); } }