public void StringifiesValueMonadCorrectly() { var monad = new ValueMonad <Int32>(2020); var visitor = new StringifierVisitor <Int32>(); var stringifyRes = monad.Accept(visitor); Assert.IsNotNull(stringifyRes); Assert.IsTrue(stringifyRes.Contains("2020", StringComparison.InvariantCultureIgnoreCase)); Assert.IsTrue(stringifyRes.Contains("value", StringComparison.InvariantCultureIgnoreCase)); }
public void DifferentReturnStringValueIsNotEqual() { var value = "SomeVal"; var monad = new ValueMonad <String>(value); var asserterVisitor = new AssertValueVisitor <String> { ExpectedValue = "SomeOtherVal", AreEqual = false }; monad.Accept(asserterVisitor); }
public void ReturnStringValueIsEqual() { var value = "SomeVal"; var monad = new ValueMonad <String>(value); var asserterVisitor = new AssertValueVisitor <String> { ExpectedValue = value, AreEqual = true }; monad.Accept(asserterVisitor); }
public void DifferentReturnIntValueIsNotEqual() { var value = 2020; var monad = new ValueMonad <Int32>(value); var asserterVisitor = new AssertValueVisitor <Int32> { ExpectedValue = 0, AreEqual = false }; monad.Accept(asserterVisitor); }
public void ReturnIntValueIsEqual() { var value = 2020; var monad = new ValueMonad <Int32>(value); var asserterVisitor = new AssertValueVisitor <Int32> { ExpectedValue = value, AreEqual = true }; monad.Accept(asserterVisitor); }
public void BindReturnsTheSecondValueOFDifferentType() { var firstVal = 1; var firstMonad = new ValueMonad <Int32>(firstVal); var secondMonad = firstMonad.Bind(val => new ValueMonad <String>($"First val is: {val}.")); var asserterVisitor = new AssertValueVisitor <String> { ExpectedValue = "First val is: 1.", AreEqual = true }; secondMonad.Accept(asserterVisitor); }
public void BindDoesntReturnADifferentValue() { var firstVal = 1; var firstMonad = new ValueMonad <Int32>(firstVal); var secondMonad = firstMonad.Bind(val => new ValueMonad <Int32>(val + 1)); var asserterVisitor = new AssertValueVisitor <Int32> { ExpectedValue = 0, AreEqual = false }; secondMonad.Accept(asserterVisitor); }
public void BindReturnsTheSecondValue() { var firstVal = 1; var firstMonad = new ValueMonad <Int32>(firstVal); var secondMonad = firstMonad.Bind(val => new ValueMonad <Int32>(val + 1)); var asserterVisitor = new AssertValueVisitor <Int32> { ExpectedValue = firstVal + 1, AreEqual = true }; secondMonad.Accept(asserterVisitor); }