From 5a88a06551a91d545eb430f85dfa25d9fc14ccb5 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 26 Apr 2022 11:04:09 +0100 Subject: [PATCH] [ci skip] Move AsArrayValue tests to CoreTests --- X10D.Tests/src/Collections/ArrayTests.cs | 23 ------------ X10D.Tests/src/Core/CoreTests.cs | 48 ++++++++++++++++++------ 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/X10D.Tests/src/Collections/ArrayTests.cs b/X10D.Tests/src/Collections/ArrayTests.cs index 02784f4..cc053ff 100644 --- a/X10D.Tests/src/Collections/ArrayTests.cs +++ b/X10D.Tests/src/Collections/ArrayTests.cs @@ -1,34 +1,11 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using X10D.Collections; -using X10D.Core; namespace X10D.Tests.Collections; [TestClass] public class ArrayTests { - [TestMethod] - [DataRow(1)] - [DataRow("f")] - [DataRow(true)] - public void AsArrayShouldGiveLength1(object o) - { - object[] array = o.AsArrayValue()!; - Assert.IsNotNull(array); - Assert.IsTrue(array.Length == 1); - } - - [TestMethod] - [DataRow(1)] - [DataRow("f")] - [DataRow(true)] - public void AsArrayShouldContainObject(object o) - { - object[] array = o.AsArrayValue()!; - Assert.IsNotNull(array); - Assert.AreEqual(o, array[0]); - } - [TestMethod] public void AsReadOnlyShouldBeReadOnly() { diff --git a/X10D.Tests/src/Core/CoreTests.cs b/X10D.Tests/src/Core/CoreTests.cs index 0084c43..79c3305 100644 --- a/X10D.Tests/src/Core/CoreTests.cs +++ b/X10D.Tests/src/Core/CoreTests.cs @@ -7,20 +7,46 @@ namespace X10D.Tests.Core; public class CoreTests { [TestMethod] - public void AsArrayShouldBeLength1() + [DataRow(1)] + [DataRow("f")] + [DataRow(true)] + public void AsArrayValue_ShouldBeLength1_GivenValue(object o) { - Assert.AreEqual(1, 0.AsArrayValue().Length); - Assert.AreEqual(1, string.Empty.AsArrayValue().Length); - Assert.AreEqual(1, true.AsArrayValue().Length); - Assert.AreEqual(1, ((object?)null).AsArrayValue().Length); + object[] array = o.AsArrayValue()!; + Assert.IsNotNull(array); + Assert.IsTrue(array.Length == 1); } - + [TestMethod] - public void AsEnumerableShouldBeLength1() + [DataRow(1)] + [DataRow("f")] + [DataRow(true)] + public void AsArrayValue_ShouldContainValue_Given_Value(object o) { - Assert.AreEqual(1, 0.AsEnumerableValue().Count()); - Assert.AreEqual(1, string.Empty.AsEnumerableValue().Count()); - Assert.AreEqual(1, true.AsEnumerableValue().Count()); - Assert.AreEqual(1, ((object?)null).AsEnumerableValue().Count()); + object[] array = o.AsArrayValue()!; + Assert.IsNotNull(array); + Assert.AreEqual(o, array[0]); + } + + [TestMethod] + [DataRow(1)] + [DataRow("f")] + [DataRow(true)] + public void AsEnumerableValue_ShouldBeLength1_GivenValue(object o) + { + IEnumerable array = o.AsEnumerableValue()!; + Assert.IsNotNull(array); + Assert.IsTrue(array.Count() == 1); + } + + [TestMethod] + [DataRow(1)] + [DataRow("f")] + [DataRow(true)] + public void AsEnumerableValue_ShouldContainValue_Given_Value(object o) + { + IEnumerable array = o.AsEnumerableValue()!; + Assert.IsNotNull(array); + Assert.AreEqual(o, array.ElementAt(0)); } }