コード例 #1
0
        public void TermResultListConverter_ConvertErrorValueNullTest()
        {
            // setup test
            TermResultListConverter conv = new TermResultListConverter();

            // run test
            Assert.ThrowsException <ArgumentNullException>(() => conv.Convert(null, typeof(string), null, "en-us"));

            // validate results
        }
コード例 #2
0
        public void TermResultListConverter_ConvertErrorTargetTypeTest()
        {
            // setup test
            TermResultListConverter conv = new TermResultListConverter();
            DiceResult diceResult        = this.dice.Roll("d20", this.roller);

            // run test
            Assert.ThrowsException <ArgumentException>(() => conv.Convert(diceResult.Results, typeof(int), null, "en-us"));

            // validate results
        }
コード例 #3
0
        public void TermResultListConverter_ConvertComplexTextTest()
        {
            // setup test
            TermResultListConverter conv = new TermResultListConverter();
            DiceResult diceResult        = this.dice.Roll("4d6k3 + d8 + 5", this.roller);

            // run test
            string result = conv.Convert(diceResult.Results, typeof(string), null, "en-us") as string;

            // validate results
            Assert.IsNotNull(result);
            Assert.AreEqual("3, 3, 3, 3*, 3", result);
        }
コード例 #4
0
        public void TermResultListConverter_ConvertEmptyResultListTest()
        {
            // setup test
            TermResultListConverter    conv = new TermResultListConverter();
            IReadOnlyList <TermResult> list = new List <TermResult>();

            // run test
            string result = conv.Convert(list, typeof(string), null, "en-us") as string;

            // validate results
            Assert.IsNotNull(result);
            Assert.AreEqual(string.Empty, result);
        }
コード例 #5
0
        /// <summary>
        /// Formats the specified list of term results into the corresponding text format.
        /// </summary>
        /// <param name="helper">Html helper</param>
        /// <param name="results">Term results to convert</param>
        /// <returns>Text representation for the list.</returns>
        public static string DisplayResultsFor(this HtmlHelper helper, IReadOnlyList <TermResult> results)
        {
            string result = (string)converter.Convert(results, typeof(string), null, "en-us");

            return(result);
        }