From 045604d33921ddca37d17007e63a420e2d42c29b Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Sun, 3 May 2020 15:28:56 +0100 Subject: [PATCH 01/14] Move ReflectionTests --- .../Umbraco.Core}/ReflectionTests.cs | 27 +++---------------- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 3 insertions(+), 25 deletions(-) rename src/{Umbraco.Tests/Clr => Umbraco.Tests.UnitTests/Umbraco.Core}/ReflectionTests.cs (54%) diff --git a/src/Umbraco.Tests/Clr/ReflectionTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/ReflectionTests.cs similarity index 54% rename from src/Umbraco.Tests/Clr/ReflectionTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/ReflectionTests.cs index f3704c8552..063a8c2621 100644 --- a/src/Umbraco.Tests/Clr/ReflectionTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/ReflectionTests.cs @@ -2,7 +2,7 @@ using NUnit.Framework; using Umbraco.Core; -namespace Umbraco.Tests.Clr +namespace Umbraco.Tests.UnitTests.Umbraco.Core { [TestFixture] public class ReflectionTests @@ -25,37 +25,16 @@ namespace Umbraco.Tests.Clr Assert.Contains(typeof(object), types); } - [Test] - public void GetInterfacesIsOk() - { - // tests that GetInterfaces gets _all_ interfaces - // so the AllInterfaces extension method is useless - - var type = typeof(Class2); - var interfaces = type.GetInterfaces(); - Assert.AreEqual(2, interfaces.Length); - Assert.Contains(typeof(IInterface1), interfaces); - Assert.Contains(typeof(IInterface2), interfaces); - } - #region Test Objects - interface IInterface1 - { } - - interface IInterface2 : IInterface1 + private class Class1 { - void Method(); } - class Class1 : IInterface2 + private class Class2 : Class1 { - public void Method() { } } - class Class2 : Class1 - { } - #endregion } } diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index a832d84ef1..615463bff1 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -302,7 +302,6 @@ - From 72071a536bfb7e28f2542275389f46a16d80908a Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Sun, 3 May 2020 15:51:46 +0100 Subject: [PATCH 02/14] Move ReflectionUtilitiesTests --- .../Umbraco.Core}/ReflectionUtilitiesTests.cs | 14 ++++---------- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 4 insertions(+), 11 deletions(-) rename src/{Umbraco.Tests/Clr => Umbraco.Tests.UnitTests/Umbraco.Core}/ReflectionUtilitiesTests.cs (98%) diff --git a/src/Umbraco.Tests/Clr/ReflectionUtilitiesTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/ReflectionUtilitiesTests.cs similarity index 98% rename from src/Umbraco.Tests/Clr/ReflectionUtilitiesTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/ReflectionUtilitiesTests.cs index c885f364dc..0f48f2cea2 100644 --- a/src/Umbraco.Tests/Clr/ReflectionUtilitiesTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/ReflectionUtilitiesTests.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; +using Newtonsoft.Json; using NUnit.Framework; using Umbraco.Core; -using System.Linq; -using Newtonsoft.Json; -namespace Umbraco.Tests.Clr +namespace Umbraco.Tests.UnitTests.Umbraco.Core { [TestFixture] public class ReflectionUtilitiesTests @@ -104,8 +104,6 @@ namespace Umbraco.Tests.Clr [Test] public void EmitMethodEmitsStaticStatic() { - // static types cannot be used as type arguments - //var method = ReflectionUtilities.EmitMethod("Method"); var method = ReflectionUtilities.EmitMethod(typeof (StaticClass1), "Method"); method(); } @@ -205,10 +203,6 @@ namespace Umbraco.Tests.Clr (var getter3, var setter3) = ReflectionUtilities.EmitPropertyGetterAndSetter("Value3"); Assert.AreEqual(42, getter3(class1)); setter3(class1, 42); - - // this is not supported yet - //var getter4 = ReflectionUtilities.EmitPropertyGetter("Value1", returned: typeof(int)); - //Assert.AreEqual(42, getter1(class1)); } [Test] @@ -448,7 +442,7 @@ namespace Umbraco.Tests.Clr var propInt4 = type4.GetProperty("IntValue"); Assert.IsNotNull(propInt4); - // ... if explicitely getting a value type + // ... if explicitly getting a value type var getterInt4T = ReflectionUtilities.EmitPropertyGetter(propInt4); Assert.IsNotNull(getterInt4T); var valueInt4T = getterInt4T(object4); diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 615463bff1..7284f617f4 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -117,7 +117,6 @@ - From 6693ea0ff79d3f283d41740d38288585947f5aab Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Sun, 3 May 2020 15:57:45 +0100 Subject: [PATCH 03/14] Move DeepCloneableListTests --- .../Collections/DeepCloneableListTests.cs | 13 +++++-------- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) rename src/{Umbraco.Tests => Umbraco.Tests.UnitTests/Umbraco.Core}/Collections/DeepCloneableListTests.cs (94%) diff --git a/src/Umbraco.Tests/Collections/DeepCloneableListTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/DeepCloneableListTests.cs similarity index 94% rename from src/Umbraco.Tests/Collections/DeepCloneableListTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/DeepCloneableListTests.cs index 37e5b2081d..305a392311 100644 --- a/src/Umbraco.Tests/Collections/DeepCloneableListTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/DeepCloneableListTests.cs @@ -1,13 +1,10 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using NUnit.Framework; using Umbraco.Core.Collections; using Umbraco.Core.Models; -namespace Umbraco.Tests.Collections +namespace Umbraco.Tests.UnitTests.Umbraco.Core.Collections { [TestFixture] public class DeepCloneableListTests @@ -85,7 +82,7 @@ namespace Umbraco.Tests.Collections list.Add(new TestClone()); list.Add(new TestClone()); - var cloned = (DeepCloneableList)list.DeepClone(); + var cloned = (DeepCloneableList) list.DeepClone(); //Test that each item in the sequence is equal - based on the equality comparer of TestClone (i.e. it's ID) Assert.IsTrue(list.SequenceEqual(cloned)); @@ -111,8 +108,8 @@ namespace Umbraco.Tests.Collections Id = Guid.NewGuid(); } - public Guid Id { get; private set; } - public bool IsClone { get; private set; } + public Guid Id { get; } + public bool IsClone { get; } public object DeepClone() { @@ -145,7 +142,7 @@ namespace Umbraco.Tests.Collections if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; - return Equals((TestClone)obj); + return Equals((TestClone) obj); } /// diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 7284f617f4..ab6d9e052e 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -248,7 +248,6 @@ - From 07d72d55621843c2c95132a0439c982def3dee8d Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Sun, 3 May 2020 16:03:45 +0100 Subject: [PATCH 04/14] Move OrderedHashSetTests --- .../Umbraco.Core}/Collections/OrderedHashSetTests.cs | 9 ++++----- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) rename src/{Umbraco.Tests => Umbraco.Tests.UnitTests/Umbraco.Core}/Collections/OrderedHashSetTests.cs (87%) diff --git a/src/Umbraco.Tests/Collections/OrderedHashSetTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/OrderedHashSetTests.cs similarity index 87% rename from src/Umbraco.Tests/Collections/OrderedHashSetTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/OrderedHashSetTests.cs index a98348751b..df7f004884 100644 --- a/src/Umbraco.Tests/Collections/OrderedHashSetTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/OrderedHashSetTests.cs @@ -1,9 +1,8 @@ using System; using NUnit.Framework; -using Umbraco.Core; using Umbraco.Core.Collections; -namespace Umbraco.Tests.Collections +namespace Umbraco.Tests.UnitTests.Umbraco.Core.Collections { [TestFixture] public class OrderedHashSetTests @@ -12,7 +11,7 @@ namespace Umbraco.Tests.Collections public void Keeps_Last() { var list = new OrderedHashSet(keepOldest: false); - var items = new[] { new MyClass("test"), new MyClass("test"), new MyClass("test") }; + var items = new[] {new MyClass("test"), new MyClass("test"), new MyClass("test")}; foreach (var item in items) { list.Add(item); @@ -27,7 +26,7 @@ namespace Umbraco.Tests.Collections public void Keeps_First() { var list = new OrderedHashSet(keepOldest: true); - var items = new[] { new MyClass("test"), new MyClass("test"), new MyClass("test") }; + var items = new[] {new MyClass("test"), new MyClass("test"), new MyClass("test")}; foreach (var item in items) { list.Add(item); @@ -60,7 +59,7 @@ namespace Umbraco.Tests.Collections if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; - return Equals((MyClass)obj); + return Equals((MyClass) obj); } public override int GetHashCode() diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index ab6d9e052e..3a32ee17fc 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -117,7 +117,6 @@ - From eabf6f459bcefbe54009d14c2ba71cd991b98842 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 14:39:10 +0100 Subject: [PATCH 05/14] Move TestClone class --- src/Umbraco.Tests.Common/TestClone.cs | 77 +++++++++++++++++++ .../Collections/DeepCloneableListTests.cs | 77 +------------------ .../Cache/DeepCloneAppCacheTests.cs | 12 +-- 3 files changed, 85 insertions(+), 81 deletions(-) create mode 100644 src/Umbraco.Tests.Common/TestClone.cs diff --git a/src/Umbraco.Tests.Common/TestClone.cs b/src/Umbraco.Tests.Common/TestClone.cs new file mode 100644 index 0000000000..5fd0aa30e2 --- /dev/null +++ b/src/Umbraco.Tests.Common/TestClone.cs @@ -0,0 +1,77 @@ +using System; +using Umbraco.Core.Models; + +namespace Umbraco.Tests.Common +{ + public class TestClone : IDeepCloneable, IEquatable + { + public TestClone(Guid id) + { + Id = id; + IsClone = true; + } + + public TestClone() + { + Id = Guid.NewGuid(); + } + + public Guid Id { get; } + public bool IsClone { get; } + + public object DeepClone() + { + return new TestClone(Id); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object. + public bool Equals(TestClone other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Id.Equals(other.Id); + } + + /// + /// Determines whether the specified object is equal to the current object. + /// + /// + /// true if the specified object is equal to the current object; otherwise, false. + /// + /// The object to compare with the current object. + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((TestClone)obj); + } + + /// + /// Serves as the default hash function. + /// + /// + /// A hash code for the current object. + /// + public override int GetHashCode() + { + return Id.GetHashCode(); + } + + public static bool operator ==(TestClone left, TestClone right) + { + return Equals(left, right); + } + + public static bool operator !=(TestClone left, TestClone right) + { + return Equals(left, right) == false; + } + } +} diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/DeepCloneableListTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/DeepCloneableListTests.cs index 305a392311..bcfe142d8d 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/DeepCloneableListTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/DeepCloneableListTests.cs @@ -1,8 +1,7 @@ -using System; -using System.Linq; +using System.Linq; using NUnit.Framework; using Umbraco.Core.Collections; -using Umbraco.Core.Models; +using Umbraco.Tests.Common; namespace Umbraco.Tests.UnitTests.Umbraco.Core.Collections { @@ -94,77 +93,5 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Collections Assert.AreNotSame(item, clone); } } - - public class TestClone : IDeepCloneable, IEquatable - { - public TestClone(Guid id) - { - Id = id; - IsClone = true; - } - - public TestClone() - { - Id = Guid.NewGuid(); - } - - public Guid Id { get; } - public bool IsClone { get; } - - public object DeepClone() - { - return new TestClone(Id); - } - - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// - /// true if the current object is equal to the parameter; otherwise, false. - /// - /// An object to compare with this object. - public bool Equals(TestClone other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Id.Equals(other.Id); - } - - /// - /// Determines whether the specified object is equal to the current object. - /// - /// - /// true if the specified object is equal to the current object; otherwise, false. - /// - /// The object to compare with the current object. - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((TestClone) obj); - } - - /// - /// Serves as the default hash function. - /// - /// - /// A hash code for the current object. - /// - public override int GetHashCode() - { - return Id.GetHashCode(); - } - - public static bool operator ==(TestClone left, TestClone right) - { - return Equals(left, right); - } - - public static bool operator !=(TestClone left, TestClone right) - { - return Equals(left, right) == false; - } - } } } diff --git a/src/Umbraco.Tests/Cache/DeepCloneAppCacheTests.cs b/src/Umbraco.Tests/Cache/DeepCloneAppCacheTests.cs index 63e481e9a5..f7b39590f2 100644 --- a/src/Umbraco.Tests/Cache/DeepCloneAppCacheTests.cs +++ b/src/Umbraco.Tests/Cache/DeepCloneAppCacheTests.cs @@ -12,7 +12,7 @@ using Umbraco.Core.Composing; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; -using Umbraco.Tests.Collections; +using Umbraco.Tests.Common; using Umbraco.Tests.TestHelpers; using Umbraco.Web.Cache; @@ -41,12 +41,12 @@ namespace Umbraco.Tests.Cache [Test] public void Clones_List() { - var original = new DeepCloneableList(ListCloneBehavior.Always); - original.Add(new DeepCloneableListTests.TestClone()); - original.Add(new DeepCloneableListTests.TestClone()); - original.Add(new DeepCloneableListTests.TestClone()); + var original = new DeepCloneableList(ListCloneBehavior.Always); + original.Add(new TestClone()); + original.Add(new TestClone()); + original.Add(new TestClone()); - var val = _provider.GetCacheItem>("test", () => original); + var val = _provider.GetCacheItem>("test", () => original); Assert.AreEqual(original.Count, val.Count); foreach (var item in val) From 06a1671f950b9cd356d79eaa34483508283bb796 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 14:39:45 +0100 Subject: [PATCH 06/14] Move ClaimsIdentityExtensionsTests --- .../Umbraco.Core}/ClaimsIdentityExtensionsTests.cs | 3 +-- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) rename src/{Umbraco.Tests/CoreThings => Umbraco.Tests.UnitTests/Umbraco.Core}/ClaimsIdentityExtensionsTests.cs (96%) diff --git a/src/Umbraco.Tests/CoreThings/ClaimsIdentityExtensionsTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/ClaimsIdentityExtensionsTests.cs similarity index 96% rename from src/Umbraco.Tests/CoreThings/ClaimsIdentityExtensionsTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/ClaimsIdentityExtensionsTests.cs index 4f728c3861..76f928ca46 100644 --- a/src/Umbraco.Tests/CoreThings/ClaimsIdentityExtensionsTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/ClaimsIdentityExtensionsTests.cs @@ -3,9 +3,8 @@ using System.Collections.Generic; using System.Security.Claims; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Web; -namespace Umbraco.Tests.CoreThings +namespace Umbraco.Tests.UnitTests.Umbraco.Core { public class ClaimsIdentityExtensionsTests { diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 9bc7e71fad..602a35f727 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -122,7 +122,6 @@ - From 3da8fd4a9803c247045e398f9c586c992da9b9ca Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 14:41:48 +0100 Subject: [PATCH 07/14] Move AttemptTests --- .../Umbraco.Core}/AttemptTests.cs | 3 +-- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) rename src/{Umbraco.Tests/CoreThings => Umbraco.Tests.UnitTests/Umbraco.Core}/AttemptTests.cs (92%) diff --git a/src/Umbraco.Tests/CoreThings/AttemptTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/AttemptTests.cs similarity index 92% rename from src/Umbraco.Tests/CoreThings/AttemptTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/AttemptTests.cs index a004095243..9a16c5b10f 100644 --- a/src/Umbraco.Tests/CoreThings/AttemptTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/AttemptTests.cs @@ -1,12 +1,11 @@ using NUnit.Framework; using Umbraco.Core; -namespace Umbraco.Tests.CoreThings +namespace Umbraco.Tests.UnitTests.Umbraco.Core { [TestFixture] public class AttemptTests { - [Test] public void AttemptIf() { diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 602a35f727..30d2751826 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -244,7 +244,6 @@ - From 958b4f431ea3fdbe80ccfa80a52ae880e4ff1a8b Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 14:47:08 +0100 Subject: [PATCH 08/14] Move DelegateExtensionsTests --- .../Umbraco.Tests.UnitTests.csproj | 1 + .../CoreThings/DelegateExtensionsTests.cs | 38 ------------------- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 3 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 src/Umbraco.Tests/CoreThings/DelegateExtensionsTests.cs diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj b/src/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj index 67d822fb03..24627b2722 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj @@ -25,6 +25,7 @@ + diff --git a/src/Umbraco.Tests/CoreThings/DelegateExtensionsTests.cs b/src/Umbraco.Tests/CoreThings/DelegateExtensionsTests.cs deleted file mode 100644 index 87b2f4c03b..0000000000 --- a/src/Umbraco.Tests/CoreThings/DelegateExtensionsTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using Lucene.Net.Index; -using NUnit.Framework; -using Umbraco.Core; - -namespace Umbraco.Tests.CoreThings -{ - [TestFixture] - public class DelegateExtensionsTests - { - [Test] - public void Only_Executes_Specific_Count() - { - const int maxTries = 5; - var totalTries = 0; - DelegateExtensions.RetryUntilSuccessOrMaxAttempts((currentTry) => - { - totalTries = currentTry; - return Attempt.Fail(); - }, 5, TimeSpan.FromMilliseconds(10)); - - Assert.AreEqual(maxTries, totalTries); - } - - [Test] - public void Quits_On_Success_Count() - { - var totalTries = 0; - DelegateExtensions.RetryUntilSuccessOrMaxAttempts((currentTry) => - { - totalTries = currentTry; - return totalTries == 2 ? Attempt.Succeed() : Attempt.Fail(); - }, 5, TimeSpan.FromMilliseconds(10)); - - Assert.AreEqual(2, totalTries); - } - } -} diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 30d2751826..1ea8d465e6 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -252,7 +252,6 @@ - From cb3a5d6b97c7a2cb01f281130b086c2a4c2a3f84 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 14:48:57 +0100 Subject: [PATCH 09/14] Move EnumerableExtensionsTests --- .../Umbraco.Core/DelegateExtensionsTests.cs | 38 +++++++++++++++++++ .../EnumerableExtensionsTests.cs | 5 +-- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 src/Umbraco.Tests.UnitTests/Umbraco.Core/DelegateExtensionsTests.cs rename src/{Umbraco.Tests/CoreThings => Umbraco.Tests.UnitTests/Umbraco.Core}/EnumerableExtensionsTests.cs (98%) diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/DelegateExtensionsTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/DelegateExtensionsTests.cs new file mode 100644 index 0000000000..a3e36c8ae6 --- /dev/null +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/DelegateExtensionsTests.cs @@ -0,0 +1,38 @@ +using System; +using Lucene.Net.Index; +using NUnit.Framework; +using Umbraco.Core; + +namespace Umbraco.Tests.UnitTests.Umbraco.Core +{ + [TestFixture] + public class DelegateExtensionsTests + { + [Test] + public void Only_Executes_Specific_Count() + { + const int maxTries = 5; + var totalTries = 0; + DelegateExtensions.RetryUntilSuccessOrMaxAttempts((currentTry) => + { + totalTries = currentTry; + return Attempt.Fail(); + }, 5, TimeSpan.FromMilliseconds(10)); + + Assert.AreEqual(maxTries, totalTries); + } + + [Test] + public void Quits_On_Success_Count() + { + var totalTries = 0; + DelegateExtensions.RetryUntilSuccessOrMaxAttempts((currentTry) => + { + totalTries = currentTry; + return totalTries == 2 ? Attempt.Succeed() : Attempt.Fail(); + }, 5, TimeSpan.FromMilliseconds(10)); + + Assert.AreEqual(2, totalTries); + } + } +} diff --git a/src/Umbraco.Tests/CoreThings/EnumerableExtensionsTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/EnumerableExtensionsTests.cs similarity index 98% rename from src/Umbraco.Tests/CoreThings/EnumerableExtensionsTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/EnumerableExtensionsTests.cs index e734713c76..32e039f26a 100644 --- a/src/Umbraco.Tests/CoreThings/EnumerableExtensionsTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/EnumerableExtensionsTests.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NUnit.Framework; using Umbraco.Core; -namespace Umbraco.Tests.CoreThings +namespace Umbraco.Tests.UnitTests.Umbraco.Core { [TestFixture] public class EnumerableExtensionsTests diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 1ea8d465e6..acb5b7398e 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -458,7 +458,6 @@ - From 299a461afbe1580dea6516a40cd3ff47c99a1f13 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 14:50:10 +0100 Subject: [PATCH 10/14] Move EnumExtensionsTests --- .../Umbraco.Core}/EnumExtensionsTests.cs | 2 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) rename src/{Umbraco.Tests/CoreThings => Umbraco.Tests.UnitTests/Umbraco.Core}/EnumExtensionsTests.cs (97%) diff --git a/src/Umbraco.Tests/CoreThings/EnumExtensionsTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/EnumExtensionsTests.cs similarity index 97% rename from src/Umbraco.Tests/CoreThings/EnumExtensionsTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/EnumExtensionsTests.cs index faa15b0077..d5ea4d2677 100644 --- a/src/Umbraco.Tests/CoreThings/EnumExtensionsTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/EnumExtensionsTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Web.Trees; -namespace Umbraco.Tests.CoreThings +namespace Umbraco.Tests.UnitTests.Umbraco.Core { [TestFixture] public class EnumExtensionsTests diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index acb5b7398e..18ee81a9c7 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -122,7 +122,6 @@ - From 449bf55060969ebf21a4cf782e300448b1827079 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 14:54:19 +0100 Subject: [PATCH 11/14] Move GuidUtilsTests --- .../Umbraco.Core}/GuidUtilsTests.cs | 2 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) rename src/{Umbraco.Tests/CoreThings => Umbraco.Tests.UnitTests/Umbraco.Core}/GuidUtilsTests.cs (95%) diff --git a/src/Umbraco.Tests/CoreThings/GuidUtilsTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/GuidUtilsTests.cs similarity index 95% rename from src/Umbraco.Tests/CoreThings/GuidUtilsTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/GuidUtilsTests.cs index 639d85b4ff..62e0955d78 100644 --- a/src/Umbraco.Tests/CoreThings/GuidUtilsTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/GuidUtilsTests.cs @@ -2,7 +2,7 @@ using NUnit.Framework; using Umbraco.Core; -namespace Umbraco.Tests.CoreThings +namespace Umbraco.Tests.UnitTests.Umbraco.Core { public class GuidUtilsTests { diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 18ee81a9c7..6ab2a06491 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -122,7 +122,6 @@ - From 663adc1db7931510de24676b721005b146a2a2c3 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 14:56:24 +0100 Subject: [PATCH 12/14] Move HexEncoderTests --- .../Umbraco.Core}/HexEncoderTests.cs | 2 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) rename src/{Umbraco.Tests/CoreThings => Umbraco.Tests.UnitTests/Umbraco.Core}/HexEncoderTests.cs (97%) diff --git a/src/Umbraco.Tests/CoreThings/HexEncoderTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/HexEncoderTests.cs similarity index 97% rename from src/Umbraco.Tests/CoreThings/HexEncoderTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/HexEncoderTests.cs index 588fff83e8..f22c3f2ac1 100644 --- a/src/Umbraco.Tests/CoreThings/HexEncoderTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/HexEncoderTests.cs @@ -3,7 +3,7 @@ using System.Text; using NUnit.Framework; using Umbraco.Core; -namespace Umbraco.Tests.CoreThings +namespace Umbraco.Tests.UnitTests.Umbraco.Core { public class HexEncoderTests { diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 6ab2a06491..432caf7b04 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -122,7 +122,6 @@ - From 7aadae68d8273ffb0a218522eb7f55e76e7a813f Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 14:59:14 +0100 Subject: [PATCH 13/14] Move VersionExtensionTests --- .../Umbraco.Core}/VersionExtensionTests.cs | 4 ++-- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) rename src/{Umbraco.Tests/CoreThings => Umbraco.Tests.UnitTests/Umbraco.Core}/VersionExtensionTests.cs (86%) diff --git a/src/Umbraco.Tests/CoreThings/VersionExtensionTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/VersionExtensionTests.cs similarity index 86% rename from src/Umbraco.Tests/CoreThings/VersionExtensionTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/VersionExtensionTests.cs index 5799e28b87..a4ab15afe7 100644 --- a/src/Umbraco.Tests/CoreThings/VersionExtensionTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/VersionExtensionTests.cs @@ -2,7 +2,7 @@ using NUnit.Framework; using Umbraco.Core; -namespace Umbraco.Tests.CoreThings +namespace Umbraco.Tests.UnitTests.Umbraco.Core { [TestFixture] public class VersionExtensionTests @@ -18,7 +18,7 @@ namespace Umbraco.Tests.CoreThings [TestCase(0, 0, 1, 1, "0.0.1.0")] [TestCase(0, 0, 0, 1, "0.0.0.0")] [TestCase(7, 3, 0, 0, "7.2.2147483647.2147483647")] - public void Subract_Revision(int major, int minor, int build, int rev, string outcome) + public void Subtract_Revision(int major, int minor, int build, int rev, string outcome) { var version = new Version(major, minor, build, rev); diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 432caf7b04..0e08e282a8 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -463,7 +463,6 @@ - From 5d5c7ba95e59d96bb8a2888b6e9ed9c9e8f05bbd Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Thu, 11 Jun 2020 15:13:35 +0100 Subject: [PATCH 14/14] Move XmlExtensionsTests --- .../Umbraco.Core}/XmlExtensionsTests.cs | 2 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) rename src/{Umbraco.Tests/CoreThings => Umbraco.Tests.UnitTests/Umbraco.Core}/XmlExtensionsTests.cs (96%) diff --git a/src/Umbraco.Tests/CoreThings/XmlExtensionsTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/XmlExtensionsTests.cs similarity index 96% rename from src/Umbraco.Tests/CoreThings/XmlExtensionsTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/XmlExtensionsTests.cs index 62e385beff..ae3762ef57 100644 --- a/src/Umbraco.Tests/CoreThings/XmlExtensionsTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/XmlExtensionsTests.cs @@ -3,7 +3,7 @@ using System.Xml.Linq; using NUnit.Framework; using Umbraco.Core; -namespace Umbraco.Tests.CoreThings +namespace Umbraco.Tests.UnitTests.Umbraco.Core { [TestFixture] public class XmlExtensionsTests diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 0e08e282a8..6455d4f7cc 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -465,7 +465,6 @@ -