Пример #1
0
        [InlineData("42,42", 10, 10, "42,42")]                              // decimal to decimal
        public void Convert_ConvertDifferentNumbersFromAnyNumberSystemToAny_Should_ConvertCorrectly(string number, int currentSystem, int neededSystem, string expected)
        {
            /*Act*/
            string actual = NumberConverterService.Convert(number, currentSystem, neededSystem);

            /*Assert*/
            Assert.Equal(expected, actual);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("[Application can convert integer (10) and fraction (10,5) numbers]\n");

            try {
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("Current number system [2-36]: ");
                int currentSystem = int.Parse(Console.ReadLine());
                Console.Write("Needed number system [2-36]: ");
                int neededSystem = int.Parse(Console.ReadLine());
                Console.Write("Number: ");
                string number = Console.ReadLine();

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"Answer: {NumberConverterService.Convert(number, currentSystem, neededSystem)}");
            }
            catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"[Error]: {e.Message}");
            }

            Console.ReadLine();
        }
Пример #3
0
 [InlineData("656.z2", 26, 10)]  // number system is lower than used char from alphabet
 public void Convert_TryToConvertInvalidNumber_Should_ThrowArgumentException(string number, int currentSystem, int neededSystem)
 {
     /*Assert*/
     Assert.Throws <ArgumentException>(() => NumberConverterService.Convert(number, currentSystem, neededSystem));
 }
Пример #4
0
 [InlineData(10, 42)]    // far from the boundary
 public void Convert_TryToConvertDataWithInvalidNumberSystem_Should_ThrowIndexOutOfRangeException(int currentSystem, int neededSystem)
 {
     /*Assert*/
     Assert.Throws <IndexOutOfRangeException>(() => NumberConverterService.Convert(string.Empty, currentSystem, neededSystem));
 }