Ejemplo n.º 1
0
        public void NoneTest()
        {
            CurrencyName a;

            a = ConverterToCurrencyName.Convert("юань");
            Assert.AreEqual(a, CurrencyName.None);
        }
Ejemplo n.º 2
0
        public void EuroTest()
        {
            CurrencyName a;

            a = ConverterToCurrencyName.Convert("Є");
            Assert.AreEqual(a, CurrencyName.Euro);
        }
Ejemplo n.º 3
0
        public void HryvnaTest()
        {
            CurrencyName a;

            a = ConverterToCurrencyName.Convert("грн");
            Assert.AreEqual(a, CurrencyName.UAH);
        }
Ejemplo n.º 4
0
        public void DollarTest()
        {
            CurrencyName a;

            a = ConverterToCurrencyName.Convert("$");
            Assert.AreEqual(a, CurrencyName.Dollar);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///  Method Read, for reading from file.
        /// </summary>
        public void Read(List <Currency> ls)
        {
            StreamReader Reader = new StreamReader("File.txt", System.Text.Encoding.Default);
            string       sLine  = string.Empty;

            while (!Reader.EndOfStream)
            {
                Currency tmp = new Currency();

                for (int i = 0; i < 2; i++)
                {
                    sLine = Reader.ReadLine();
                    if (sLine == null)
                    {
                        throw new ArgumentNullException("Wrong name of currency!");
                    }

                    if (i == 0 && sLine != null)
                    {
                        CurrencyName toCheck = ConverterToCurrencyName.Convert(sLine);
                        if (toCheck != CurrencyName.None)
                        {
                            tmp.CurrencyName = toCheck;
                        }
                        else
                        {
                            throw new ArgumentNullException("Wrong name of currency!");
                        }
                    }
                    else if (i == 1 && sLine != null)
                    {
                        tmp.Amount = double.Parse(sLine);
                    }
                }
                ls.Add(tmp);
            }
            Reader.Close();
        }