From 039fdbacb36b8998dc4970a1de3a2b3f44ed3620 Mon Sep 17 00:00:00 2001 From: David Arno Date: Mon, 26 Nov 2018 17:27:41 +0000 Subject: [PATCH] #51 - Added three tests to satisfy the three rules laid out in a comment in that issue, regarding how null and Option<> compare. --- .../SuccincT/Options/OptionEqualityTests.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/SuccincT.Tests/SuccincT/Options/OptionEqualityTests.cs b/tests/SuccincT.Tests/SuccincT/Options/OptionEqualityTests.cs index b6f912b..def1aeb 100644 --- a/tests/SuccincT.Tests/SuccincT/Options/OptionEqualityTests.cs +++ b/tests/SuccincT.Tests/SuccincT/Options/OptionEqualityTests.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System; +using NUnit.Framework; using SuccincT.Options; using static NUnit.Framework.Assert; @@ -56,7 +57,7 @@ public void ComparingSomeValueWithNull_ResultsInNotEqual() } [Test] - public void ComparingNoneWithNull_ResultsInNotEqual() + public void ComparingNoneWithNull_ResultsInEqual() { var a = Option.None(); IsFalse(a.Equals(null)); @@ -83,11 +84,20 @@ public void EmptyOptionsOfDifferentTypes_AreNotReferentiallyEqual() } [Test] - public void X() + public void CreatingAnOptionFromNull_ResultIsTrueWhenComparedToNone() { Option a = null; - var isNull = a == null; - IsTrue(isNull); + IsTrue(a == Option.None()); } + + [Test] + public void CreatingAnOptionFromNull_ResultIsTrueWhenComparedToNull() + { + Option a = null; + IsTrue(a == null); + } + + [Test] + public void CreatingASomeFromNull_Throws() => Throws(() => Option.Some(null)); } } \ No newline at end of file