/// <summary>
        /// Get toolbar sub menu test data from an external JSON file.
        /// </summary>
        public static IEnumerable <object[]> SubMenuElementTestData()
        {
            IDictionary <string, string[]> inputData;
            IList <object[]> outputData = new List <object[]>();

            string jsonFilePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                                "cfg", SeleniumTestUtils.GetConfigDir(), "ToolbarMenus.json"));

            if (!File.Exists(jsonFilePath))
            {
                throw new FileNotFoundException($"Could not find file '{jsonFilePath}'.");
            }

            inputData = JsonConvert.DeserializeObject <Dictionary <string, string[]> >(File.ReadAllText(jsonFilePath));

            foreach (string keyName in inputData.Keys)
            {
                foreach (string value in inputData[keyName])
                {
                    outputData.Add(new object[] { keyName, value });
                }
            }

            return(outputData);
        }
        /// <summary>
        /// Get hyperlink element test data from an external JSON file.
        /// </summary>
        public static IEnumerable <object[]> HyperlinkElementTestData()
        {
            IDictionary <string, PageElements> inputData;
            IList <object[]> outputData = new List <object[]>();

            string jsonFilePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                                "cfg", SeleniumTestUtils.GetConfigDir(), "HyperlinkElements.json"));

            if (!File.Exists(jsonFilePath))
            {
                throw new FileNotFoundException($"Could not find file '{jsonFilePath}'.");
            }

            inputData = JsonConvert.DeserializeObject <Dictionary <string, PageElements> >(
                File.ReadAllText(jsonFilePath));

            foreach (string pageSegment in inputData.Keys)
            {
                foreach (HyperlinkElement element in inputData[pageSegment].Hyperlinks)
                {
                    outputData.Add(new object[] { pageSegment, element.Title, element.Text, element.Position });
                }
            }

            return(outputData);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get car model test data from external JSON files.
        /// </summary>
        public static IEnumerable <object[]> GetCarModelTestData()
        {
            IDictionary <string, CarData> carData;
            IDictionary <string, ZipCode> zipCodes;
            IList <object[]> outputData = new List <object[]>();

            string jsonFilePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                                "cfg", SeleniumTestUtils.GetConfigDir(), "CarModels.json"));

            if (!File.Exists(jsonFilePath))
            {
                throw new FileNotFoundException($"Could not find file '{jsonFilePath}'.");
            }

            carData = JsonConvert.DeserializeObject <Dictionary <string, CarData> >(
                File.ReadAllText(jsonFilePath));

            jsonFilePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                         "cfg", SeleniumTestUtils.GetConfigDir(), "ZipCodes.json"));

            if (!File.Exists(jsonFilePath))
            {
                throw new FileNotFoundException($"Could not find file '{jsonFilePath}'.");
            }

            zipCodes = JsonConvert.DeserializeObject <Dictionary <string, ZipCode> >(
                File.ReadAllText(jsonFilePath));

            foreach (string zipCode in zipCodes.Keys)
            {
                foreach (string make in carData.Keys)
                {
                    foreach (CarModel model in carData[make].Models)
                    {
                        outputData.Add(new object[] { make, model.Name, zipCode });
                    }
                }
            }

            return(outputData);
        }