title: How to create unit test for method that reads file and has file path as parameter
body: <p>I know that this is probably quite easy, but since I've just started learning unit testing, I'm a little confused with all of the possibilities.</p>
  
  <p>I've got this pretty simple method which should read integers numbers from file (the condition is that file contains only integer numbers, each of them stored in a new line).</p>
  
  <pre><code>public static IEnumerable&lt;int&gt; ReadIntegers(string file)
  {
      using (var stream = File.OpenText(file))
      {
          string line;
          while ((line = stream.ReadLine()) != null)
          {
              yield return int.Parse(line);
          }
      }
  }
  </code></pre>
  
  <p>One thing before I continue, please don't suggest me to refactor method, I've found it and I want to learn how to write unit test for this particular input parameter and output value.</p>
  
  <p>I've found on the another topic that someone suggested to create a testfile in test case and than try to compare expected with actual result, something like this :</p>
  
  <pre><code> [Test]
   public void ShouldValidateReadingOfTheFile()
   {
       string path = @"E:\TestFile.txt";
       using (var sw = File.AppendText(path))
       {
           sw.WriteLine(1);
           sw.WriteLine(100);
       }
       var expected = new List&lt;int&gt;() { 1, 100 };
       var actual = TestProject.Merge.ReadIntegersFromFile(path);
       Assert.IsTrue(expected.SequenceEqual(actual));
   }
  </code></pre>
  
  <p>I want to ask you is this a bad practice ? Do you have different approach ? Is there any other idea about different tests for this method.Thank You !</p>