Skip to content

Commit

Permalink
#51 - Added three tests to satisfy the three rules laid out in a comm…
Browse files Browse the repository at this point in the history
…ent in that issue, regarding how null and Option<> compare.
  • Loading branch information
DavidArno committed Nov 26, 2018
1 parent 1fbb2e6 commit 039fdba
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tests/SuccincT.Tests/SuccincT/Options/OptionEqualityTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using System;
using NUnit.Framework;
using SuccincT.Options;
using static NUnit.Framework.Assert;

Expand Down Expand Up @@ -56,7 +57,7 @@ public void ComparingSomeValueWithNull_ResultsInNotEqual()
}

[Test]
public void ComparingNoneWithNull_ResultsInNotEqual()
public void ComparingNoneWithNull_ResultsInEqual()
{
var a = Option<string>.None();
IsFalse(a.Equals(null));
Expand All @@ -83,11 +84,20 @@ public void EmptyOptionsOfDifferentTypes_AreNotReferentiallyEqual()
}

[Test]
public void X()
public void CreatingAnOptionFromNull_ResultIsTrueWhenComparedToNone()
{
Option<string> a = null;
var isNull = a == null;
IsTrue(isNull);
IsTrue(a == Option<string>.None());
}

[Test]
public void CreatingAnOptionFromNull_ResultIsTrueWhenComparedToNull()
{
Option<string> a = null;
IsTrue(a == null);
}

[Test]
public void CreatingASomeFromNull_Throws() => Throws<ArgumentNullException>(() => Option<string>.Some(null));
}
}

0 comments on commit 039fdba

Please sign in to comment.