Пример #1
0
        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));
        }
Пример #2
0
        /// <summary>
        /// Instantiates a visitor to stringify the input monad.
        /// </summary>
        /// <typeparam name="TMonadValue">Value type of the monad.</typeparam>
        /// <param name="monad">Monad to serialize.</param>
        /// <returns>The stringified input monad.</returns>
        protected String StringifyMonad <TMonadValue>(IMonad <TMonadValue> monad)
        {
            IMonadVisitor <TMonadValue, String> stringifier = new StringifierVisitor <TMonadValue>();

            return(monad.Accept(stringifier));
        }