Sanchime.Functional/Sanchime.Functional.Test/OptionTest.cs

33 lines
645 B
C#

using Sanchime.Functional.Products;
using Sanchime.Toolkits;
using static Sanchime.Functional.Products.Optional;
namespace Sanchime.Functional.Test;
public class Tests
{
[SetUp]
public void Setup()
{
}
[Test]
public void OptionNone()
{
var foo = (Option<int> o) => o;
var result = foo(Optional.None);
Assert.AreEqual(result, Optional.None);
}
[Test]
[TestCase(-1)]
[TestCase(0)]
[TestCase(1)]
[TestCase(null)]
public void OptionMap(int? value)
{
var result = Some(value).Map(x => x * 10);
Assert.AreEqual(result, Some(value * 10));
}
}