FruityFoundation/Base.Tests/Extensions/MaybeExtensionTests.cs
Kyle Ratti 18d2e1616b
v1.0
2022-02-13 11:59:47 -05:00

31 lines
838 B
C#

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<string>.Empty(), Array.Empty<string>().FirstOrEmpty());
Assert.AreEqual(Maybe<string>.Create("banana"), new[] { "banana" }.FirstOrEmpty());
}
[Test]
public void TestToMaybe()
{
Assert.AreEqual(Maybe<int>.Empty(), Maybe<int>.Empty());
Assert.AreEqual(Maybe<string>.Create("banana"), "banana".ToMaybe());
Assert.AreNotEqual(Maybe<int>.Create(293921), Maybe<int>.Create(2));
}
[Test]
public void MaybeNullableTests()
{
Assert.IsNull(Maybe<int>.Empty().ToNullable());
Assert.IsNull(Maybe<int>.Create(0, _ => false).ToNullable());
}
}