From 7424a6432dd325c56c50d88189e34bdb37abc643 Mon Sep 17 00:00:00 2001 From: yv01p Date: Tue, 23 Dec 2025 17:51:09 +0000 Subject: [PATCH] test(unit): add ContentMoveOperationService interface contract tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verifies interface exists, extends IService, and has all required methods. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- ...ntentMoveOperationServiceInterfaceTests.cs | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/ContentMoveOperationServiceInterfaceTests.cs diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/ContentMoveOperationServiceInterfaceTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/ContentMoveOperationServiceInterfaceTests.cs new file mode 100644 index 0000000000..1f98002d9c --- /dev/null +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/ContentMoveOperationServiceInterfaceTests.cs @@ -0,0 +1,72 @@ +using System.Reflection; +using NUnit.Framework; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Services; + +namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Services; + +[TestFixture] +public class ContentMoveOperationServiceInterfaceTests +{ + [Test] + public void Interface_Exists_And_Is_Public() + { + var interfaceType = typeof(IContentMoveOperationService); + + Assert.That(interfaceType, Is.Not.Null); + Assert.That(interfaceType.IsInterface, Is.True); + Assert.That(interfaceType.IsPublic, Is.True); + } + + [Test] + public void Interface_Extends_IService() + { + var interfaceType = typeof(IContentMoveOperationService); + + Assert.That(typeof(IService).IsAssignableFrom(interfaceType), Is.True); + } + + [Test] + [TestCase("Move", new[] { typeof(IContent), typeof(int), typeof(int) })] + [TestCase("EmptyRecycleBin", new[] { typeof(int) })] + [TestCase("RecycleBinSmells", new Type[] { })] + [TestCase("Copy", new[] { typeof(IContent), typeof(int), typeof(bool), typeof(int) })] + [TestCase("Copy", new[] { typeof(IContent), typeof(int), typeof(bool), typeof(bool), typeof(int) })] + public void Interface_Has_Required_Method(string methodName, Type[] parameterTypes) + { + var interfaceType = typeof(IContentMoveOperationService); + var method = interfaceType.GetMethod(methodName, parameterTypes); + + Assert.That(method, Is.Not.Null, $"Method {methodName} should exist with specified parameters"); + } + + [Test] + public void Interface_Has_Sort_Methods() + { + var interfaceType = typeof(IContentMoveOperationService); + + // Sort with IEnumerable + var sortContentMethod = interfaceType.GetMethods() + .FirstOrDefault(m => m.Name == "Sort" && + m.GetParameters().Length == 2 && + m.GetParameters()[0].ParameterType.IsGenericType); + + // Sort with IEnumerable + var sortIdsMethod = interfaceType.GetMethods() + .FirstOrDefault(m => m.Name == "Sort" && + m.GetParameters().Length == 2 && + m.GetParameters()[0].ParameterType == typeof(IEnumerable)); + + Assert.That(sortContentMethod, Is.Not.Null, "Sort(IEnumerable, int) should exist"); + Assert.That(sortIdsMethod, Is.Not.Null, "Sort(IEnumerable, int) should exist"); + } + + [Test] + public void Implementation_Inherits_ContentServiceBase() + { + var implementationType = typeof(ContentMoveOperationService); + var baseType = typeof(ContentServiceBase); + + Assert.That(baseType.IsAssignableFrom(implementationType), Is.True); + } +}