FruityFoundation/Base.Tests/Structures/MaybeExtensionTests.cs
Kyle Ratti 0e7e161327
1.3.0
2023-08-01 22:32:23 -04:00

30 lines
697 B
C#

using System;
using FruityFoundation.Base.Structures;
using NUnit.Framework;
namespace Base.Tests.Structures;
public class MaybeExtensionTests
{
[Test]
public void EnumerableFirstOrEmptyTests()
{
Assert.AreEqual(Maybe.Empty<string>(), Array.Empty<string>().FirstOrEmpty());
Assert.AreEqual(Maybe.Just<string>("banana"), new[] { "banana" }.FirstOrEmpty());
}
[Test]
public void TestToMaybe()
{
Assert.AreEqual(Maybe.Empty<int>(), Maybe.Empty<int>());
Assert.AreNotEqual(Maybe.Just(293921), Maybe.Just(2));
}
[Test]
public void MaybeNullableTests()
{
Assert.IsNull(Maybe.Empty<int>().ToNullable());
Assert.IsNull(Maybe.Just(0, hasValue: _ => false).ToNullable());
}
}