Example #1
0
        static int OnRun(Options options)
        {
            IList <TestModel> tests;

            if (options.Tests.Count() == 0)
            {
                //
                // If no specific test is designated, convert all.
                //

                tests = new List <TestModel>(Tests.TestModels);
            }
            else
            {
                //
                // Convert test patterns for all selected tests.
                //

                try
                {
                    tests = options.Tests.Select(t => Tests.Find(t)).ToList();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Invalid test name: {ex.Message}");
                    return((int)ReturnCode.InvalidTestName);
                }
            }

            //
            // Validate base paths.
            //

            if (Directory.Exists(options.TestCodeBasePath) == false)
            {
                Console.WriteLine("Test code base path does not exist.");
                return((int)ReturnCode.TestCodeBasePathDoesNotExist);
            }
            else if (Directory.Exists(options.PatternBasePath) == false)
            {
                Console.WriteLine("Pattern base path does not exist.");
                return((int)ReturnCode.PatternBasePathDoesNotExist);
            }

            //
            // Create test converter.
            //

            TestConverter tc = new TestConverter(
                options.TestCodeBasePath, options.PatternBasePath, options.Verbose);

            foreach (TestModel test in tests)
            {
                Console.WriteLine($"Converting {test.TestCodePath} ...");
                tc.Convert(test);
            }

            return((int)ReturnCode.Success);
        }
Example #2
0
        public void BaseConverter_SourceTypeTests()
        {
            int    defTestInt    = 10;
            string defTestString = "Test string";

            TestConverter conv1 = new TestConverter();
            TestConverter conv2 = new TestConverter(defTestInt, defTestString);

            // test that the correct default value is returned when the source type is incorrect
            Assert.AreEqual(default(int), conv1.Convert(1, typeof(int), null, null),
                            "Test converter Convert did not return the appropriate default value when given an incorrect source type");
            Assert.AreEqual(defTestInt, conv2.Convert(1, typeof(int), null, null),
                            "Test converter Convert did not return the appropriate default value when given an incorrect source type");
            Assert.AreEqual(String.Empty, conv1.ConvertBack("1", typeof(string), null, null),
                            "Test converter ConvertBack did not return the appropriate default value when given an incorrect source type");
            Assert.AreEqual(defTestString, conv2.ConvertBack("1", typeof(string), null, null),
                            "Test converter ConvertBack did not return the appropriate default value when given an incorrect source type");
        }