public void ConstructorShouldThrowWhenScoreIsNotAnInteger(string line) { GradeScoreFactory factory = new GradeScoreFactory(); ArgumentException ex = Assert.Throws <ArgumentException>(() => factory.Create(line, 1)); Assert.That(ex.Message, Does.Contain("score is not a valid value on line 1. It must be an integer.")); }
public void ConstructorShouldThrowWhenLastNameIsEmptyOrWhiteSpace(string line) { GradeScoreFactory factory = new GradeScoreFactory(); ArgumentException ex = Assert.Throws <ArgumentException>(() => factory.Create(line, 1)); Assert.That(ex.Message, Does.Contain("lastName is not a valid value on line 1. It must be a string and cannot be empty.")); }
public void CreateShouldThrowWhenLineIsNull() { GradeScoreFactory factory = new GradeScoreFactory(); ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => factory.Create(null, 1)); Assert.That(ex.Message, Does.Contain("line 1 is not a valid score. It cannot be null.")); }
public void CreateShouldThrowWhenLineHasBadPartsCount(string line) { GradeScoreFactory factory = new GradeScoreFactory(); ArgumentException ex = Assert.Throws <ArgumentException>(() => factory.Create(line, 1)); Assert.That(ex.Message, Does.Contain("line 1 is not a valid score. It must have the format \"First Name, Last Name, Score\".")); }
public void CreateShouldPass(int score) { GradeScoreFactory factory = new GradeScoreFactory(); string line = $"first name, last name, {score}"; GradeScore gradeScore = factory.Create(line, 1); Assert.That(gradeScore.FirstName, Is.EqualTo("first name")); Assert.That(gradeScore.LastName, Is.EqualTo("last name")); Assert.That(gradeScore.Score, Is.EqualTo(score)); }