Exemplo n.º 1
0
 public void TestV()
 {
     Assert.AreEqual(
         5,
         RomanNumerals.ToArabic("V")
         );
 }
Exemplo n.º 2
0
 public void Test2019()
 {
     Assert.AreEqual(
         "MMXIX",
         RomanNumerals.FromArabic(2019)
         );
 }
Exemplo n.º 3
0
 public void TestIV()
 {
     Assert.AreEqual(
         4,
         RomanNumerals.ToArabic("IV")
         );
 }
Exemplo n.º 4
0
 public void TestC()
 {
     Assert.AreEqual(
         100,
         RomanNumerals.ToArabic("C")
         );
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 6
0
 public void Test0()
 {
     Assert.AreEqual(
         0,
         RomanNumerals.ToArabic("0")
         );
 }
Exemplo n.º 7
0
 public void TestXI()
 {
     Assert.AreEqual(
         11,
         RomanNumerals.ToArabic("XI")
         );
 }
Exemplo n.º 8
0
 public void TestII()
 {
     Assert.AreEqual(
         2,
         RomanNumerals.ToArabic("II")
         );
 }
Exemplo n.º 9
0
 public void Test500()
 {
     Assert.AreEqual(
         "D",
         RomanNumerals.FromArabic(500)
         );
 }
Exemplo n.º 10
0
 public void Test9()
 {
     Assert.AreEqual(
         "IX",
         RomanNumerals.FromArabic(9)
         );
 }
Exemplo n.º 11
0
 public void Test11()
 {
     Assert.AreEqual(
         "XI",
         RomanNumerals.FromArabic(11)
         );
 }
Exemplo n.º 12
0
 public void Test6()
 {
     Assert.AreEqual(
         "VI",
         RomanNumerals.FromArabic(6)
         );
 }
Exemplo n.º 13
0
 public void Test5()
 {
     Assert.AreEqual(
         "V",
         RomanNumerals.FromArabic(5)
         );
 }
Exemplo n.º 14
0
 public void Test4()
 {
     Assert.AreEqual(
         "IV",
         RomanNumerals.FromArabic(4)
         );
 }
Exemplo n.º 15
0
 public void Test2()
 {
     Assert.AreEqual(
         "II",
         RomanNumerals.FromArabic(2)
         );
 }
Exemplo n.º 16
0
 public void Test1000()
 {
     Assert.AreEqual(
         "M",
         RomanNumerals.FromArabic(1000)
         );
 }
Exemplo n.º 17
0
 public void TestIX()
 {
     Assert.AreEqual(
         9,
         RomanNumerals.ToArabic("IX")
         );
 }
Exemplo n.º 18
0
 public void Test39()
 {
     Assert.AreEqual(
         "XXXIX",
         RomanNumerals.FromArabic(39)
         );
 }
Exemplo n.º 19
0
 public void TestX()
 {
     Assert.AreEqual(
         10,
         RomanNumerals.ToArabic("X")
         );
 }
Exemplo n.º 20
0
 public void Test246()
 {
     Assert.AreEqual(
         "CCXLVI",
         RomanNumerals.FromArabic(246)
         );
 }
Exemplo n.º 21
0
 public void TestL()
 {
     Assert.AreEqual(
         50,
         RomanNumerals.ToArabic("L")
         );
 }
Exemplo n.º 22
0
 public void Test1066()
 {
     Assert.AreEqual(
         "MLXVI",
         RomanNumerals.FromArabic(1066)
         );
 }
Exemplo n.º 23
0
        public void ParseRomanNumeralsToDigits_InvalidFormat_ThrowsKeyNotFoundException()
        {
            void action() => RomanNumerals.ParseRomanNumeralsToDigits("XZLI");

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

            Assert.Equal(converted, input);
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
        }
    }
Exemplo n.º 28
0
        public void NumeralConverter(int arabic, string numeral)
        {
            var romanNumerals = new RomanNumerals();
            var result        = romanNumerals.CalculateRomanResult(arabic);

            result.Should().Be(numeral);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }