Ejemplo n.º 1
0
        public void BuildSaveRestoreTest()
        {
            var build = DataGenerator.CreateBuild(3);

            Assert.IsNotNull(build, "Failed creating Build.");

            // Save ToString text
            var src = build.ToString();

            // Start edit.
            build.BeginEdit();

            // Edit
            build.BuildName = "edited";
            build.Solutions.RemoveAt(1);

            // Cancel edit.
            build.CancelEdit();

            // Check.
            Assert.AreEqual(src, build.ToString(), "Failed save/edit");
        }
Ejemplo n.º 2
0
        public void StorageConstructorTest()
        {
            // Create storage.
            var storage = DataGenerator.CreateStorage(10, 25);

            Assert.IsNotNull(storage, "Failed creating Storage.");

            // Create writer.
            var streamWriter = new StreamWriter(XmlFileName);
            var xmlWriter    = XmlWriter.Create(streamWriter);

            if (xmlWriter != null)
            {
                // Create serializer.
                var serializer = new DataContractSerializer(typeof(Storage));

                // Serialize.
                serializer.WriteObject(xmlWriter, storage);
                xmlWriter.Close();
                streamWriter.Close();

                // Create reader.
                var streamReader = new StreamReader(XmlFileName);
                var xmlReader    = XmlReader.Create(streamReader);

                // Deserialize.
                var deserializedStorage = (Storage)serializer.ReadObject(xmlReader);
                xmlReader.Close();
                streamReader.Close();

                Assert.IsNotNull(deserializedStorage, "Failed deserializing.");

                Assert.AreEqual(storage.ToString(), deserializedStorage.ToString(), "Failed serialize/deserialize.");
            }
            else
            {
                Assert.Fail("Failed creation xmlWriter");
            }
        }
Ejemplo n.º 3
0
        public void BuildSerializationTest()
        {
            var build = DataGenerator.CreateBuild(3);

            Assert.IsNotNull(build, "Failed creating Build.");

            // Create writer.
            var streamWriter = new StreamWriter(XmlFileName);
            var xmlWriter    = XmlWriter.Create(streamWriter);

            if (xmlWriter != null)
            {
                // Create serializer.
                var serializer = new DataContractSerializer(typeof(Build));

                // Serialize.
                serializer.WriteObject(xmlWriter, build);
                xmlWriter.Close();
                streamWriter.Close();

                // Create reader.
                var streamReader = new StreamReader(XmlFileName);
                var xmlReader    = XmlReader.Create(streamReader);

                // Deserialize.
                var deserializedBuild = (Build)serializer.ReadObject(xmlReader);
                xmlReader.Close();
                streamReader.Close();

                Assert.IsNotNull(deserializedBuild, "Failed deserializing.");

                Assert.AreEqual(build.ToString(), deserializedBuild.ToString(), "Failed serialize/deserialize.");
            }
            else
            {
                Assert.Fail("Failed creation xmlWriter");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Tests save/restore
        /// </summary>[TestMethod]
        public void StorageSaveRestoreTest()
        {
            // Create storage.
            var storage = DataGenerator.CreateStorage(10, 25);

            Assert.IsNotNull(storage, "Failed creating Storage.");

            // Keep sourcestorage ToString
            var src = storage.ToString();

            // Start edit.
            storage.BeginEdit();

            // Edit
            storage.Version = "edited";
            storage.Builds.RemoveAt(1);

            // Cancel edit.
            storage.CancelEdit();

            // Check.
            Assert.AreEqual(src, storage.ToString(), "Failed save/edit");
        }
 public ValidateQuestionsTests()
 {
     ExamsToCheck = DataGenerator.Initialize(null);
     //ExamsToCheck = ExamsToCheck.Where(e => !e.Code.Equals("AZ-100", StringComparison.CurrentCultureIgnoreCase)).ToList();
 }
Ejemplo n.º 6
0
        public void PreloadSiteTest()
        {
            var ExamsToCheck = DataGenerator.Initialize(null);


            Parallel.ForEach(ExamsToCheck, (exam) =>
            {
                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);
                chromeOptions.AcceptInsecureCertificates = true;

                string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                using (ChromeDriver driver = new ChromeDriver(path, chromeOptions))
                {
                    for (int i = 1; i <= exam.Questions.Count; i++)
                    {
                        driver.Navigate().GoToUrl($"https://www.exam-answer.com/{exam.Provider}/{exam.Code}/question{i}");
                    }
                }
            });



            //ChromeOptions chromeOptions = new ChromeOptions();
            //chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);
            //chromeOptions.AcceptInsecureCertificates = true;

            //string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            //using (ChromeDriver driver = new ChromeDriver(path, chromeOptions))
            //{
            //    for (int i = 1; i <= 340; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/amazon/saa-c01/question{i}");
            //    }
            //    for (int i = 1; i <= 130; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/microsoft/az-900/question{i}");
            //    }

            //    for (int i = 1; i <= 60; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/salesforce/salesforce-certified-field-service-lightning-consultant/question{i}");
            //    }

            //    for (int i = 1; i <= 100; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/salesforce/crt-251/question{i}");
            //    }

            //    for (int i = 1; i <= 112; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/microsoft/az-100/question{i}");
            //    }

            //    for (int i = 1; i <= 243; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/microsoft/az-300/question{i}");
            //    }

            //    for (int i = 1; i <= 73; i++)
            //    {
            //        driver.Navigate().GoToUrl($"https://www.exam-answer.com/microsoft/az-400/question{i}");
            //    }
            //}
        }
Ejemplo n.º 7
0
        public void CreateExportForUdemyTest()
        {
            List <ExamEntity> exams = DataGenerator.Initialize(null);

            ExamEntity theExamToExportToUdemy = exams.FirstOrDefault(f => f.Code == "AZ-900");

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Question,Question Type (multiple-choice or multi-select),Answer Option 1,Answer Option 2,Answer Option 3,Answer Option 4,Answer Option 5,Answer Option 6,Correct Response,Explanation,Knowledge Area");

            List <QuestionEntity> theQuestions = theExamToExportToUdemy.Questions.Skip(50).Take(50).ToList();

            foreach (QuestionEntity question in theQuestions)
            {
                if (!question.Answers.Any(a => a.IsCorrect == true))
                {
                    continue;
                }

                sb.Append(question.ContentTextUdemy.Replace("\"", "\"\"").Replace(",", ""));
                sb.Append(",");

                if (question.QuestionType == QuestionType.RadioButon)
                {
                    sb.Append("multiple-choice");
                    sb.Append(",");
                }
                else if (question.QuestionType == QuestionType.CheckBox)
                {
                    sb.Append("multi-select");
                    sb.Append(",");
                }

                for (int i = 0; i < 6; i++)
                {
                    if (i < question.Answers?.Count)
                    {
                        AnswerEntity answer = question.Answers[i];
                        sb.Append(answer.Text.Replace("\"", "\"\"").Replace(",", ""));
                        sb.Append(",");
                    }
                    else
                    {
                        //sb.Append(string.Empty);
                        sb.Append(",");
                    }
                }
                if (question.QuestionType == QuestionType.CheckBox)
                {
                    sb.Append("\"");
                }
                for (int i = 0; i < 6; i++)
                {
                    if (i < question.Answers?.Count)
                    {
                        AnswerEntity answer = question.Answers[i];

                        if (answer.IsCorrect == true)
                        {
                            int indexToInsert = question.Answers.IndexOf(answer) + 1;
                            sb.Append(indexToInsert);
                            if (question.QuestionType == QuestionType.CheckBox)
                            {
                                sb.Append(",");
                            }
                        }
                    }
                }

                sb = new StringBuilder(sb.ToString().Trim(','));

                if (question.QuestionType == QuestionType.CheckBox)
                {
                    sb.Append("\"");
                }
                sb.Append(",");
                if (!string.IsNullOrEmpty(question.ExplanationText))
                {
                    sb.Append(question.ExplanationTextUdemy.Replace(",", ""));
                    sb.Append("References: ");
                    sb.Append(question.ReferenceTextUdemy.Replace(",", ""));
                }

                sb.Append(",");

                string knowledgeArea = question.Section.Replace(",", "");

                sb.Append(knowledgeArea);

                sb.Append(Environment.NewLine);
            }

            string result = sb.ToString();

            File.WriteAllText($"BulkImportUdemy{theExamToExportToUdemy.Code}.csv", result);
        }