public void TestLoadingFileWithSingleRecord() { //Define the expected data List <Answer> expectedData = new List <Answer>() { new Answer() { SubmittedAnswerId = 12345, SubmitDateTime = DateTime.Parse("2018-01-30T08:57:00.00"), Correct = 1, Progress = 0, UserId = 56789, ExerciseId = 23, Difficulty = "5", Subject = "Geschiedenis", Domain = "-", LearningObjective = "Industrial Revolution" } }; //Create the JSON file loader IAnswerDataJsonFileLoader fileLoader = new AnswerDataJsonFileLoader(); //Load the test file List <Answer> actualData = fileLoader.LoadAnswerDataFromFile(SingleAnswerFileName); //Compare the actual data to the expected data Assert.That(actualData.Count, Is.EqualTo(expectedData.Count)); expectedData.Zip(actualData, Tuple.Create) .ToList() .ForEach(dataTuple => DataComparers.CompareAnswers(dataTuple.Item1, dataTuple.Item2)); }
public void TestLoadingNonExistentFile() { //Create the JSON file loader IAnswerDataJsonFileLoader fileLoader = new AnswerDataJsonFileLoader(); //Attempts to load the test file, which should result in a FileNotFound exception Assert.That(() => fileLoader.LoadAnswerDataFromFile(NonExistentFileName), Throws.TypeOf <FileNotFoundException>()); }
public void TestLoadingFileWithNoData() { //Define the expected data List <Answer> expectedData = new List <Answer>(); //Create the JSON file loader IAnswerDataJsonFileLoader fileLoader = new AnswerDataJsonFileLoader(); //Load the test file List <Answer> actualData = fileLoader.LoadAnswerDataFromFile(NoRecordsFileName); Assert.That(actualData.Count, Is.EqualTo(expectedData.Count)); }