示例#1
0
 public void TestV()
 {
     Assert.AreEqual(
         5,
         RomanNumerals.ToArabic("V")
         );
 }
示例#2
0
 public void Test2019()
 {
     Assert.AreEqual(
         "MMXIX",
         RomanNumerals.FromArabic(2019)
         );
 }
示例#3
0
 public void TestIV()
 {
     Assert.AreEqual(
         4,
         RomanNumerals.ToArabic("IV")
         );
 }
示例#4
0
 public void TestC()
 {
     Assert.AreEqual(
         100,
         RomanNumerals.ToArabic("C")
         );
 }
示例#5
0
        public void CollectionSortTest()
        {
            Random        rand     = new Random();
            List <string> sortList = new List <string>(COLLECTION_SIZE);

            // Fill the collection with a random assortment of roman numerals
            for (int i = 0; i < COLLECTION_SIZE; i++)
            {
                int num = rand.Next(RomanNumerals.MinValue, RomanNumerals.MaxValue);
                sortList.Add(RomanNumerals.IntegerToRoman(num));
            }

            // Sort the list with my comparer
            sortList.Sort(new RomanComparer());

            // Now iterate over the list and make sure that every element is less than the one after it
            for (int i = 0; i < sortList.Count - 2; i++)
            {
                string strLeft  = (string)sortList[i];
                string strRight = (string)sortList[i + 1];

                int nLeft  = RomanNumerals.RomanToInteger(strLeft);
                int nRight = RomanNumerals.RomanToInteger(strRight);

                Assert.IsTrue(nLeft <= nRight, "{0} is not less than {1}", strLeft, strRight);
            }
        }
示例#6
0
 public void Test0()
 {
     Assert.AreEqual(
         0,
         RomanNumerals.ToArabic("0")
         );
 }
示例#7
0
 public void TestXI()
 {
     Assert.AreEqual(
         11,
         RomanNumerals.ToArabic("XI")
         );
 }
示例#8
0
 public void TestII()
 {
     Assert.AreEqual(
         2,
         RomanNumerals.ToArabic("II")
         );
 }
示例#9
0
 public void Test500()
 {
     Assert.AreEqual(
         "D",
         RomanNumerals.FromArabic(500)
         );
 }
示例#10
0
 public void Test9()
 {
     Assert.AreEqual(
         "IX",
         RomanNumerals.FromArabic(9)
         );
 }
示例#11
0
 public void Test11()
 {
     Assert.AreEqual(
         "XI",
         RomanNumerals.FromArabic(11)
         );
 }
示例#12
0
 public void Test6()
 {
     Assert.AreEqual(
         "VI",
         RomanNumerals.FromArabic(6)
         );
 }
示例#13
0
 public void Test5()
 {
     Assert.AreEqual(
         "V",
         RomanNumerals.FromArabic(5)
         );
 }
示例#14
0
 public void Test4()
 {
     Assert.AreEqual(
         "IV",
         RomanNumerals.FromArabic(4)
         );
 }
示例#15
0
 public void Test2()
 {
     Assert.AreEqual(
         "II",
         RomanNumerals.FromArabic(2)
         );
 }
示例#16
0
 public void Test1000()
 {
     Assert.AreEqual(
         "M",
         RomanNumerals.FromArabic(1000)
         );
 }
示例#17
0
 public void TestIX()
 {
     Assert.AreEqual(
         9,
         RomanNumerals.ToArabic("IX")
         );
 }
示例#18
0
 public void Test39()
 {
     Assert.AreEqual(
         "XXXIX",
         RomanNumerals.FromArabic(39)
         );
 }
示例#19
0
 public void TestX()
 {
     Assert.AreEqual(
         10,
         RomanNumerals.ToArabic("X")
         );
 }
示例#20
0
 public void Test246()
 {
     Assert.AreEqual(
         "CCXLVI",
         RomanNumerals.FromArabic(246)
         );
 }
示例#21
0
 public void TestL()
 {
     Assert.AreEqual(
         50,
         RomanNumerals.ToArabic("L")
         );
 }
示例#22
0
 public void Test1066()
 {
     Assert.AreEqual(
         "MLXVI",
         RomanNumerals.FromArabic(1066)
         );
 }
示例#23
0
        public void ParseRomanNumeralsToDigits_InvalidFormat_ThrowsKeyNotFoundException()
        {
            void action() => RomanNumerals.ParseRomanNumeralsToDigits("XZLI");

            //void action() => SerialPortParser.ParsePort("1");
            Assert.Throws <KeyNotFoundException>(action);
        }
示例#24
0
 public void TestVI()
 {
     Assert.AreEqual(
         6,
         RomanNumerals.ToArabic("VI")
         );
 }
示例#25
0
        public void ShouldConvertToRomanNumeralAndBack(int input)
        {
            var numeral   = RomanNumerals.ToNumeral(input);
            var converted = RomanNumerals.ToInt(numeral);

            Assert.Equal(converted, input);
        }
示例#26
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the text displayed in the spin box
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void UpdateEditText()
        {
            switch (m_mode)
            {
            case DataUpDownMode.Normal:
                Text = m_currentValue.ToString();
                break;

            case DataUpDownMode.Letters:
                Text = AlphaOutline.NumToAlphaOutline(m_currentValue);
                break;

            case DataUpDownMode.LettersLowerCase:
                Text = AlphaOutline.NumToAlphaOutline(m_currentValue).ToLower();
                break;

            case DataUpDownMode.Roman:
                Text = RomanNumerals.IntToRoman(m_currentValue);
                break;

            case DataUpDownMode.RomanLowerCase:
                Text = RomanNumerals.IntToRoman(m_currentValue).ToLower();
                break;
            }
        }
示例#27
0
    // This method creates all the planet data for a star
    void CreatePlanetData(Star star)
    {
        for (int i = 0; i < star.numberOfPlanets; i++)
        {
            string name = star.starName + " " + RomanNumerals.RomanNumeralGenerator(star.planetList.Count + 1);

            int    random = Random.Range(1, 100);
            string type   = "";

            if (random < 40)
            {
                type = availablePlanetTypes[0];
            }
            else if (40 <= random && random < 50)
            {
                type = availablePlanetTypes[1];
            }
            else
            {
                type = availablePlanetTypes[2];
            }

            Planet planetData = new Planet(name, type);
            //Debug.Log(planetData.planetName + " " + planetData.planetType );

            star.planetList.Add(planetData);
        }
    }
示例#28
0
        public void NumeralConverter(int arabic, string numeral)
        {
            var romanNumerals = new RomanNumerals();
            var result        = romanNumerals.CalculateRomanResult(arabic);

            result.Should().Be(numeral);
        }
示例#29
0
        private string GetOutlineStyle2biv(int[] rghvo, int ihvo)
        {
            // Top-level: Arabic numeral.
            // Second-level: lowercase letter.
            // Third-level (and lower): lowercase Roman numeral.
            string sNum;             // return result string
            var    sOutline   = m_cache.GetOutlineNumber(m_objRepo.GetObject(rghvo[ihvo]), false, true);
            var    cchPeriods = 0;
            var    ichPeriod  = sOutline.IndexOf('.');

            while (ichPeriod >= 0)
            {
                ++cchPeriods;
                ichPeriod = sOutline.IndexOf('.', ichPeriod + 1);
            }
            switch (cchPeriods)
            {
            case 0:
                sNum = string.Format("{0}", ihvo + 1);
                break;

            case 1:
                sNum = AlphaOutline.NumToAlphaOutline(ihvo + 1).ToLower();
                break;

            default:
                sNum = RomanNumerals.IntToRoman(ihvo + 1).ToLower();
                break;
            }
            return(sNum);
        }
示例#30
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Builds a number string for the preview window based on the given values
        /// </summary>
        /// <param name="line">The line.</param>
        /// <param name="nStartAt">The number to start at.</param>
        /// <param name="iScheme">The i scheme.</param>
        /// <param name="textBefore">The text before.</param>
        /// <param name="textAfter">The text after.</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private string GetNumberString(int line, int nStartAt, int iScheme, string textBefore,
                                       string textAfter)
        {
            int    number       = nStartAt + line;
            string numberString = string.Empty;

            switch (iScheme)
            {
            case 0:                             // 1, 2, 3'
                numberString = number.ToString();
                break;

            case 1:                             // I, II, III (Roman numerals)
                numberString = RomanNumerals.IntToRoman(number);
                break;

            case 2:                             // i, ii, iii (lower case Roman numerals)
                numberString = RomanNumerals.IntToRoman(number).ToLowerInvariant();
                break;

            case 3:                             // A, B, C
                numberString = AlphaOutline.NumToAlphaOutline(number);
                break;

            case 4:                             // a, b, c
                numberString = AlphaOutline.NumToAlphaOutline(number).ToLowerInvariant();
                break;

            case 5:                             // 01, 02, 03
                numberString = number.ToString("d2");
                break;
            }

            return(textBefore + numberString + textAfter);
        }
示例#31
0
 public void Example()
 {
     int expected = 6 * 9;
     int actual = new RomanNumerals().Answer;
     Assert.AreEqual(expected, actual);
 }
 public void TestInitialize()
 {
     romanNumerals = new RomanNumerals();
 }
 public void TestCleanup()
 {
     romanNumerals = null;
 }