public Test GetTest(string filename, int position) { string fullPath = _fileHandler.GetFileFullPath(filename); string fileContents = _fileHandler.ReadAllText(fullPath); using (var stringReader = new StringReader(fileContents)) { TestFile testFile = _testFileReader.Read(stringReader); Test test = testFile.Tests.ElementAtOrDefault(position); if (test == null) { throw new NullReferenceException("Could not find specified Test Case:" + position); } return(test); } }