Skip to content

Commit

Permalink
Merge branch 'features/Code_cleanup'
Browse files Browse the repository at this point in the history
  • Loading branch information
KeRNeLith committed Sep 20, 2018
2 parents e8d2e8e + cb3fab9 commit 1a86c62
Show file tree
Hide file tree
Showing 7 changed files with 606 additions and 10 deletions.
16 changes: 16 additions & 0 deletions src/Here.Tests/Maybe/MaybeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,37 @@ public void MaybeCompare()
Assert.AreEqual(0, maybeInt1.CompareTo((object)maybeInt2));
Assert.AreEqual(0, maybeInt2.CompareTo(maybeInt1));
Assert.AreEqual(0, maybeInt2.CompareTo((object)maybeInt1));
Assert.IsFalse(maybeInt1 < maybeInt2);
Assert.IsTrue(maybeInt1 <= maybeInt2);
Assert.IsFalse(maybeInt1 > maybeInt2);
Assert.IsTrue(maybeInt1 >= maybeInt2);

Assert.AreEqual(-1, maybeInt1.CompareTo(maybeInt3));
Assert.AreEqual(-1, maybeInt1.CompareTo((object)maybeInt3));
Assert.AreEqual(1, maybeInt3.CompareTo(maybeInt1));
Assert.AreEqual(1, maybeInt3.CompareTo((object)maybeInt1));
Assert.IsTrue(maybeInt1 < maybeInt3);
Assert.IsTrue(maybeInt1 <= maybeInt3);
Assert.IsFalse(maybeInt1 > maybeInt3);
Assert.IsFalse(maybeInt1 >= maybeInt3);

Assert.AreEqual(1, maybeInt1.CompareTo(emptyMaybeInt1));
Assert.AreEqual(1, maybeInt1.CompareTo((object)emptyMaybeInt1));
Assert.AreEqual(-1, emptyMaybeInt1.CompareTo(maybeInt1));
Assert.AreEqual(-1, emptyMaybeInt1.CompareTo((object)maybeInt1));
Assert.IsFalse(maybeInt1 < emptyMaybeInt1);
Assert.IsFalse(maybeInt1 <= emptyMaybeInt1);
Assert.IsTrue(maybeInt1 > emptyMaybeInt1);
Assert.IsTrue(maybeInt1 >= emptyMaybeInt1);

Assert.AreEqual(0, emptyMaybeInt1.CompareTo(emptyMaybeInt2));
Assert.AreEqual(0, emptyMaybeInt1.CompareTo((object)emptyMaybeInt2));
Assert.AreEqual(0, emptyMaybeInt2.CompareTo(emptyMaybeInt1));
Assert.AreEqual(0, emptyMaybeInt2.CompareTo((object)emptyMaybeInt1));
Assert.IsFalse(emptyMaybeInt1 < emptyMaybeInt2);
Assert.IsTrue(emptyMaybeInt1 <= emptyMaybeInt2);
Assert.IsFalse(emptyMaybeInt1 > emptyMaybeInt2);
Assert.IsTrue(emptyMaybeInt1 >= emptyMaybeInt2);

// Mixed
Assert.AreEqual(1, maybeInt1.CompareTo(null)); // Null initialize a Maybe.None
Expand Down
114 changes: 114 additions & 0 deletions src/Here.Tests/Result/ResultLogicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,119 @@ public void ResultLogicErrorEquality()
Assert.IsTrue(logicOk1 != null);
Assert.IsTrue(null != logicOk1);
}

[Test]
public void ResultLogicCompare()
{
// Results
var logicOk1 = new ResultLogic();
var logicOk2 = new ResultLogic();
var logicWarn1 = new ResultLogic(true, "My warning", null);
var logicWarn2 = new ResultLogic(true, "My warning", null);
var logicWarn3 = new ResultLogic(true, "My warning 2", null);
var logicFail1 = new ResultLogic(false, "My failure", null);
var logicFail2 = new ResultLogic(false, "My failure", null);
var logicFail3 = new ResultLogic(false, "My failure 2", null);

Assert.IsFalse(logicOk1 < logicOk2);
Assert.IsTrue(logicOk1 <= logicOk2);
Assert.IsFalse(logicOk1 > logicOk2);
Assert.IsTrue(logicOk1 >= logicOk2);

Assert.IsFalse(logicOk1 < logicWarn1);
Assert.IsFalse(logicOk1 <= logicWarn1);
Assert.IsTrue(logicOk1 > logicWarn1);
Assert.IsTrue(logicOk1 >= logicWarn1);

Assert.IsFalse(logicOk1 < logicFail1);
Assert.IsFalse(logicOk1 <= logicFail1);
Assert.IsTrue(logicOk1 > logicFail1);
Assert.IsTrue(logicOk1 >= logicFail1);


Assert.IsFalse(logicWarn1 < logicWarn2);
Assert.IsTrue(logicWarn1 <= logicWarn2);
Assert.IsFalse(logicWarn1 > logicWarn2);
Assert.IsTrue(logicWarn1 >= logicWarn2);

Assert.IsFalse(logicWarn1 < logicWarn3);
Assert.IsTrue(logicWarn1 <= logicWarn3);
Assert.IsFalse(logicWarn1 > logicWarn3);
Assert.IsTrue(logicWarn1 >= logicWarn3);

Assert.IsFalse(logicWarn1 < logicFail1);
Assert.IsFalse(logicWarn1 <= logicFail1);
Assert.IsTrue(logicWarn1 > logicFail1);
Assert.IsTrue(logicWarn1 >= logicFail1);


Assert.IsFalse(logicFail1 < logicFail2);
Assert.IsTrue(logicFail1 <= logicFail2);
Assert.IsFalse(logicFail1 > logicFail2);
Assert.IsTrue(logicFail1 >= logicFail2);

Assert.IsFalse(logicFail1 < logicFail3);
Assert.IsTrue(logicFail1 <= logicFail3);
Assert.IsFalse(logicFail1 > logicFail3);
Assert.IsTrue(logicFail1 >= logicFail3);
}

[Test]
public void ResultLogicErrorCompare()
{
var customErrorObject = new CustomErrorTest { ErrorCode = -1 };

// Results
var logicOk1 = new ResultLogic<CustomErrorTest>();
var logicOk2 = new ResultLogic<CustomErrorTest>();
var logicWarn1 = new ResultLogic<CustomErrorTest>(true, "My warning", null, null);
var logicWarn2 = new ResultLogic<CustomErrorTest>(true, "My warning", null, null);
var logicWarn3 = new ResultLogic<CustomErrorTest>(true, "My warning 2", null, null);
var logicFail1 = new ResultLogic<CustomErrorTest>(false, "My failure", customErrorObject, null);
var logicFail2 = new ResultLogic<CustomErrorTest>(false, "My failure", customErrorObject, null);
var logicFail3 = new ResultLogic<CustomErrorTest>(false, "My failure 2", customErrorObject, null);

Assert.IsFalse(logicOk1 < logicOk2);
Assert.IsTrue(logicOk1 <= logicOk2);
Assert.IsFalse(logicOk1 > logicOk2);
Assert.IsTrue(logicOk1 >= logicOk2);

Assert.IsFalse(logicOk1 < logicWarn1);
Assert.IsFalse(logicOk1 <= logicWarn1);
Assert.IsTrue(logicOk1 > logicWarn1);
Assert.IsTrue(logicOk1 >= logicWarn1);

Assert.IsFalse(logicOk1 < logicFail1);
Assert.IsFalse(logicOk1 <= logicFail1);
Assert.IsTrue(logicOk1 > logicFail1);
Assert.IsTrue(logicOk1 >= logicFail1);


Assert.IsFalse(logicWarn1 < logicWarn2);
Assert.IsTrue(logicWarn1 <= logicWarn2);
Assert.IsFalse(logicWarn1 > logicWarn2);
Assert.IsTrue(logicWarn1 >= logicWarn2);

Assert.IsFalse(logicWarn1 < logicWarn3);
Assert.IsTrue(logicWarn1 <= logicWarn3);
Assert.IsFalse(logicWarn1 > logicWarn3);
Assert.IsTrue(logicWarn1 >= logicWarn3);

Assert.IsFalse(logicWarn1 < logicFail1);
Assert.IsFalse(logicWarn1 <= logicFail1);
Assert.IsTrue(logicWarn1 > logicFail1);
Assert.IsTrue(logicWarn1 >= logicFail1);


Assert.IsFalse(logicFail1 < logicFail2);
Assert.IsTrue(logicFail1 <= logicFail2);
Assert.IsFalse(logicFail1 > logicFail2);
Assert.IsTrue(logicFail1 >= logicFail2);

Assert.IsFalse(logicFail1 < logicFail3);
Assert.IsTrue(logicFail1 <= logicFail3);
Assert.IsFalse(logicFail1 > logicFail3);
Assert.IsTrue(logicFail1 >= logicFail3);
}
}
}
Loading

0 comments on commit 1a86c62

Please sign in to comment.