Пример #1
0
        public void NumToWordsReturnsValueWhole()
        {
            var    sut    = new NumConverter();
            string result = sut.NumToWords(new decimal(1000000));

            Assert.AreEqual("one million", result);
        }
Пример #2
0
        public void NumToWordsReturnsValueWholeWithMantissa()
        {
            var    sut    = new NumConverter();
            string result = sut.NumToWords(new decimal(1854600.23));

            Assert.AreEqual("one million eight hundred and fifty four thousand six hundred and twenty three cents", result);
        }
Пример #3
0
        public void GetHundredReturnsValueWithPrefix()
        {
            var    sut    = new NumConverter();
            string result = sut.GetHundred(301, "and");

            Assert.AreEqual(" three hundred and one", result);
        }
Пример #4
0
        public void GetHundredReturnsValue()
        {
            var    sut    = new NumConverter();
            string result = sut.GetHundred(300);

            Assert.AreEqual(" three hundred ", result);
        }
Пример #5
0
        public void GetLessTwentyReturnsValueWithPrefix()
        {
            Dictionary <uint, string> lessTwenty = new Dictionary <uint, string>();

            lessTwenty.Add(0, "and zero");
            lessTwenty.Add(1, "and one");
            lessTwenty.Add(2, "and two");
            lessTwenty.Add(3, "and three");
            lessTwenty.Add(4, "and four");
            lessTwenty.Add(5, "and five");
            lessTwenty.Add(6, "and six");
            lessTwenty.Add(7, "and seven");
            lessTwenty.Add(8, "and eight");
            lessTwenty.Add(9, "and nine");
            lessTwenty.Add(10, "and ten");

            lessTwenty.Add(11, "and eleven");
            lessTwenty.Add(12, "and twelve");
            lessTwenty.Add(13, "and thirteen");
            lessTwenty.Add(14, "and fourteen");
            lessTwenty.Add(15, "and fifteen");
            lessTwenty.Add(16, "and sixteen");
            lessTwenty.Add(17, "and seventeen");
            lessTwenty.Add(18, "and eighteen");
            lessTwenty.Add(19, "and nineteen");
            var sut = new NumConverter();

            foreach (var kv in lessTwenty)
            {
                string result = sut.GetLessTwenty(kv.Key, "and");
                Assert.AreEqual($"{kv.Value}", result);
            }
        }
Пример #6
0
        public void NumToWordsReturnsValueWholeMantissaOnly()
        {
            var    sut    = new NumConverter();
            string result = sut.NumToWords(new decimal(0.23));

            Assert.AreEqual("zero and twenty three cents", result);
        }
Пример #7
0
        public void NumToWordsReturnsValueWholeCharacteristicOnly()
        {
            var    sut    = new NumConverter();
            string result = sut.NumToWords(new decimal(1854600));

            Assert.AreEqual("one million eight hundred and fifty four thousand six hundred", result);
        }
Пример #8
0
 public void NumToWordsThrowsArgumentExceptionBigPrecision()
 {
     Assert.Throws(Is.TypeOf <ArgumentException>().And.Property("Message").EqualTo("AcceptOnlyTens"), () =>
     {
         var sut       = new NumConverter();
         string result = sut.NumToWords(new decimal(0.2366));
     });
 }
Пример #9
0
 public void GetLessTwentyThrowAcceptOnlyLessThanTwenty()
 {
     Assert.Throws(Is.TypeOf <ArgumentException>().And.Property("Message").EqualTo("AcceptOnlyLessThanTwentys"), () =>
     {
         var sut = new NumConverter();
         sut.GetLessTwenty(21);
     });
 }
Пример #10
0
 public void NumToWordsThrowsArgumentException()
 {
     Assert.Throws(Is.TypeOf <ArgumentException>().And.Property("Message").EqualTo("NotANumber"), () =>
     {
         var sut = new NumConverter();
         sut.NumToWords("abc");
     });
 }
Пример #11
0
 public void GetHundredThrowAcceptOnlyHundreds()
 {
     Assert.Throws(Is.TypeOf <ArgumentException>().And.Property("Message").EqualTo("AcceptOnlyHundreds"), () =>
     {
         var sut = new NumConverter();
         sut.GetHundred(1001);
     });
 }
Пример #12
0
        public void Setup()
        {
            _hexReader    = new Mock <IHexReader>();
            _numConverter = new NumConverter(_hexReader.Object);

            _poolDifficultyOne      = "00000000FFFF0000000000000000000000000000000000000000000000000000";
            _poolDifficultyOneBytes = new byte[]
            {
                0, 0, 0, 0, 255, 255, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0
            };

            _hexReader
            .Setup(x => x.ToByteArray(_poolDifficultyOne, Endian.Big))
            .Returns(_poolDifficultyOneBytes);
        }
Пример #13
0
        public void GetTensReturnsValueWithPrefix()
        {
            Dictionary <uint, string> tensDictionary = new Dictionary <uint, string>();

            tensDictionary.Add(20, "and twenty");
            tensDictionary.Add(30, "and thirty");
            tensDictionary.Add(40, "and forty");
            tensDictionary.Add(50, "and fifty");
            tensDictionary.Add(60, "and sixty");
            tensDictionary.Add(70, "and seventy");
            tensDictionary.Add(80, "and eighty");
            tensDictionary.Add(90, "and ninety");
            var sut = new NumConverter();

            foreach (var kv in tensDictionary)
            {
                string result = sut.GetTens(kv.Key, "and");
                Assert.AreEqual($"{kv.Value}", result);
            }
        }
Пример #14
0
 public void Startup()
 {
     converter = new NumConverter();
 }
Пример #15
0
 public void TestClean()
 {
     converter = null;
 }
Пример #16
0
        public void PassInstanceTest()
        {
            var sut = new NumConverter();

            Assert.IsInstanceOf <NumConverter>(sut);
        }
Пример #17
0
        public void InstantiateResultDictionary()
        {
            var sut = new NumConverter();

            Assert.IsNotNull(sut._resultDictionary);
        }