public void LoadData_CallsCreateDiplomas_WithStudentFromImportData_IfValidateStudentRecordReturnsTrue() { string path = "path"; Mock <IFileReader> fileReader = new Mock <IFileReader>(); Mock <ICustomMapper> mapper = new Mock <ICustomMapper>(); Mock <IFileWriter> fileWriter = new Mock <IFileWriter>(); Mock <IValidator> validator = new Mock <IValidator>(); StudentDataProcessor studentDataProcessor = new StudentDataProcessor(fileReader.Object, mapper.Object, fileWriter.Object, validator.Object); var finalStudents = new List <StudentModel>() { new StudentModel(), new StudentModel(), new StudentModel() }; mapper.Setup(x => x.MapToStudent(It.IsAny <IEnumerable <StudentRawModel> >())).Returns(finalStudents); validator.Setup(v => v.ValidateStudentRecord(finalStudents[0])).Returns(true); validator.Setup(v => v.ValidateStudentRecord(finalStudents[1])).Returns(true); validator.Setup(v => v.ValidateStudentRecord(finalStudents[2])).Returns(false); studentDataProcessor.LoadData(path); fileWriter.Verify(f => f.CreateDiplomas(It.IsAny <StudentModel>()), Times.Exactly(2)); }
public void LoadData_CallsImportData_OneTimeWithPath() { string path = "path"; Mock <IFileReader> fileReader = new Mock <IFileReader>(); Mock <ICustomMapper> mapper = new Mock <ICustomMapper>(); Mock <IFileWriter> fileWriter = new Mock <IFileWriter>(); Mock <IValidator> validator = new Mock <IValidator>(); StudentDataProcessor studentDataProcessor = new StudentDataProcessor(fileReader.Object, mapper.Object, fileWriter.Object, validator.Object); studentDataProcessor.LoadData(path); fileReader.Verify(x => x.ImportData(path), Times.Once); }
public void LoadData_CallsMapToStudent_WithStudentsFromImportData() { string path = "path"; Mock <IFileReader> fileReader = new Mock <IFileReader>(); Mock <ICustomMapper> mapper = new Mock <ICustomMapper>(); Mock <IFileWriter> fileWriter = new Mock <IFileWriter>(); Mock <IValidator> validator = new Mock <IValidator>(); StudentDataProcessor studentDataProcessor = new StudentDataProcessor(fileReader.Object, mapper.Object, fileWriter.Object, validator.Object); fileReader.Setup(s => s.ImportData(path)).Returns(new List <StudentRawModel>() { new StudentRawModel() }); studentDataProcessor.LoadData(path); mapper.Verify(x => x.MapToStudent(It.IsAny <IEnumerable <StudentRawModel> >()), Times.Once); }
public void LoadData_CallsValidateStudentRecord_WithStudentFromImportData() { string path = "path"; Mock <IFileReader> fileReader = new Mock <IFileReader>(); Mock <ICustomMapper> mapper = new Mock <ICustomMapper>(); Mock <IFileWriter> fileWriter = new Mock <IFileWriter>(); Mock <IValidator> validator = new Mock <IValidator>(); StudentDataProcessor studentDataProcessor = new StudentDataProcessor(fileReader.Object, mapper.Object, fileWriter.Object, validator.Object); var finalStudents = new List <StudentModel>() { new StudentModel(), new StudentModel() }; mapper.Setup(x => x.MapToStudent(It.IsAny <IEnumerable <StudentRawModel> >())).Returns(finalStudents); studentDataProcessor.LoadData(path); validator.Verify(v => v.ValidateStudentRecord(It.IsAny <StudentModel>()), Times.Exactly(finalStudents.Count)); }