Exemple #1
0
        static async Task GenerateReports(List <Prompt> prompts)
        {
            /*We will now initialize some objects that will be used as we go execute the call for each prompt */
            var           compiler = new ReportCompile();
            CourseGrabber http     = new CourseGrabber();

            var SuccessReports = new List <ReportItem>();

            /*Loop through each prompt, set up the http call, calibrate how the compiler should work and send the success reports to the Dictionary we have for keeping track of it */
            foreach (var prompt in prompts)
            {
                http.CourseID = prompt.CourseId;
                compiler.CalibrateCompiler(prompt, grabReportObject(prompt.OutFormat, prompt.Destination), http);

                var success = false;
                try
                {
                    success = await compiler.CompileReport();
                }
                catch (Exception e)
                {
                    // Display all errors in an awesome fashion.
                    ConsoleRep.Log(new string[] { "WE GOT AN ERROR BOSS!", e.Message, "Course: " + prompt.CourseId, prompt.OutFormat + " " + prompt.Destination }, ConsoleColor.Red);
                    success = false;
                }
                SuccessReports.Add(new ReportItem(prompt.OutFormat + " " + prompt.Destination + "    =====   " + (success ? "Successful" : "Error!"), success ? ConsoleColor.Green : ConsoleColor.Red));
            }

            ConsoleRep.Log(SuccessReports);
        }
Exemple #2
0
        public async void ResultsFromHttpGetAreEqual()
        {
            // the test will go on forever if this token is not set! To fix that issue, we will fail the test if it is not set.
            var token = Environment.GetEnvironmentVariable("API_TOKEN");

            Assert.False(token == null);

            var http        = new CourseGrabber("59796");
            var HttpResults = await http.grabCourseData();

            Assert.Equal(HttpResults, System.IO.File.ReadAllText(ExpRelPath + "expected.json"));
        }
Exemple #3
0
        public async Task HandlesInvalidPrompt()
        {
            // the test will go on forever if this token is not set! To fix that issue, we will fail the test if it is not set.
            var token = Environment.GetEnvironmentVariable("API_TOKEN");

            Assert.False(token == null);
            var           compiler = new ReportCompile();
            var           prompt   = new Prompt("", "", RelPath + "");
            CourseGrabber http     = new CourseGrabber(prompt.CourseId);

            compiler.CalibrateCompiler(grabReportObject(prompt.OutFormat, prompt.Destination), http);
            var res = (await compiler.CompileReport());

            Assert.True(res);
        }
Exemple #4
0
        public async Task FullProcessRuns()
        {
            // the test will go on forever if this token is not set! To fix that issue, we will fail the test if it is not set.
            var token = Environment.GetEnvironmentVariable("API_TOKEN");

            Assert.False(token == null);

            // the test will go on forever if this token is not set! To fix that issue, we will fail the test if it is not set.
            List <Prompt> prompts = new List <Prompt>()
            {
                new Prompt("59796", "JSON", RelPath + "full_generated.json"),
                new Prompt("59796", "CSV", RelPath + "full_generated.csv"),
                new Prompt("59796", "HTML", RelPath + "full_generated.html")
            };

            /*We will now initialize some objects that will be used as we go execute the call for each prompt */
            var           compiler = new ReportCompile();
            CourseGrabber http     = new CourseGrabber();

            var SuccessReports = new List <ReportItem>();

            /*Loop through each prompt, set up the http call, calibrate how the compiler should work and send the success reports to the Dictionary we have for keeping track of it */
            foreach (var prompt in prompts)
            {
                http.CourseID = prompt.CourseId;
                compiler.CalibrateCompiler(prompt, grabReportObject(prompt.OutFormat, prompt.Destination), http);

                var success = false;
                try
                {
                    success = await compiler.CompileReport();
                }
                catch (Exception e)
                {
                    // Display all errors in an awesome fashion.
                    ConsoleRep.Log(new string[] { "WE GOT AN ERROR BOSS!", e.Message, "Course: " + prompt.CourseId, prompt.OutFormat + " " + prompt.Destination }, ConsoleColor.Red);
                    success = false;
                }
                Assert.True(success);
            }
            Assert.True(FilesAreEqual(prompts[0].Destination, ExpRelPath + "expected.json"));
            Assert.True(FilesAreEqual(prompts[1].Destination, ExpRelPath + "expected.csv"));
            Assert.True(FilesAreEqual(prompts[2].Destination, ExpRelPath + "expected.html"));
        }