Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
svroonland committed Jul 9, 2020
1 parent 8cfbe6a commit 6d01cb0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions CSharpFunctionalExtensions.Tests/MaybeTests/ExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,28 @@ public void TryFind_dict_does_not_contains_key()
maybe.HasValue.Should().BeFalse();
}

[Fact]
public void ToList_gives_empty_list_if_null()
{
Maybe<MyClass> maybe = null;

List<MyClass> myClasses = maybe.ToList();

myClasses.Count.Should().Be(0);
}

[Fact]
public void ToList_gives_single_item_list_if_not_null()
{
var instance = new MyClass();
Maybe<MyClass> maybe = instance;

List<MyClass> myClasses = maybe.ToList();

myClasses.Count.Should().Be(1);
myClasses[0].Should().Be(instance);
}

private static Maybe<string> GetPropertyIfExists(MyClass myClass)
{
return myClass.Property;
Expand Down

0 comments on commit 6d01cb0

Please sign in to comment.