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