Fix and enable some unit tests which are not running locally or on pipeline builds (#19910)

* fix some test which are not running

* resolve code review comments

* Moved cleaned up tests to unit tests (as they are unit tests, not integration tests).
Removed tests marked as no longer necessary.
Update tests name to better reflect test case.

* Made explict test faster so it could run on the pipeline.

---------

Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
Dirk Seefeld
2025-08-15 09:23:39 +02:00
committed by GitHub
parent 74c9510b56
commit e2d7bb660c
3 changed files with 32 additions and 44 deletions

View File

@@ -1,7 +1,6 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Threading;
using NUnit.Framework;
using Umbraco.Cms.Core.Cache;
using Umbraco.Extensions;
@@ -13,18 +12,21 @@ public abstract class RuntimeAppCacheTests : AppCacheTests
internal abstract IAppPolicyCache AppPolicyCache { get; }
[Test]
[Explicit("Testing for timeouts cannot work on VSTS.")]
public void Can_Add_And_Expire_Struct_Strongly_Typed_With_Null()
{
var now = DateTime.Now;
AppPolicyCache.Insert("DateTimeTest", () => now, new TimeSpan(0, 0, 0, 0, 200));
Assert.AreEqual(now, AppCache.GetCacheItem<DateTime>("DateTimeTest"));
Assert.AreEqual(now, AppCache.GetCacheItem<DateTime?>("DateTimeTest"));
AppPolicyCache.Insert("DateTimeTest", () => now, new TimeSpan(0, 0, 0, 0, 20));
var cachedDateTime = AppCache.GetCacheItem<DateTime>("DateTimeTest");
var cachedDateTimeNullable = AppCache.GetCacheItem<DateTime?>("DateTimeTest");
Assert.AreEqual(now, cachedDateTime);
Assert.AreEqual(now, cachedDateTimeNullable);
Thread.Sleep(300); // sleep longer than the cache expiration
Thread.Sleep(30); // sleep longer than the cache expiration
Assert.AreEqual(default(DateTime), AppCache.GetCacheItem<DateTime>("DateTimeTest"));
Assert.AreEqual(null, AppCache.GetCacheItem<DateTime?>("DateTimeTest"));
cachedDateTime = AppCache.GetCacheItem<DateTime>("DateTimeTest");
cachedDateTimeNullable = AppCache.GetCacheItem<DateTime?>("DateTimeTest");
Assert.AreEqual(default(DateTime), cachedDateTime);
Assert.AreEqual(null, cachedDateTimeNullable);
}
[Test]

View File

@@ -28,8 +28,6 @@ public class SliderPropertyValueEditorTests
true,
new object(),
new List<string> { "some", "values" },
Guid.NewGuid(),
new GuidUdi(Constants.UdiEntityType.Document, Guid.NewGuid())
};
[TestCaseSource(nameof(InvalidCaseData))]
@@ -39,6 +37,20 @@ public class SliderPropertyValueEditorTests
Assert.IsNull(fromEditor);
}
[Test]
public void Can_Handle_Invalid_Values_From_Editor_Guid()
{
var fromEditor = FromEditor(Guid.NewGuid());
Assert.IsNull(fromEditor);
}
[Test]
public void Can_Handle_Invalid_Values_From_Editor_Udi()
{
var fromEditor = FromEditor(new GuidUdi(Constants.UdiEntityType.Document, Guid.NewGuid()));
Assert.IsNull(fromEditor);
}
[TestCase("1", 1)]
[TestCase("0", 0)]
[TestCase("-1", -1)]