1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 19:48:46 +00:00

[ci skip] Move AsArrayValue tests to CoreTests

This commit is contained in:
Oliver Booth 2022-04-26 11:04:09 +01:00
parent 8020e91647
commit 5a88a06551
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
2 changed files with 37 additions and 34 deletions

View File

@ -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()
{

View File

@ -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<object> 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<object> array = o.AsEnumerableValue()!;
Assert.IsNotNull(array);
Assert.AreEqual(o, array.ElementAt(0));
}
}