title: C# mocking Mock<StreamWriter>
body: <p>I am new to C# mocking, I am trying to read some code and I got one of the tests failing, can you please explain to me what the below source code is trying to test and when will it fail?</p>
  
  <pre><code>Mock&lt;StreamWriter&gt; _streamWriterMock;
  string[] expectedLines;
  .
  .
  .
  foreach (var line in expectedLines)
  {
      _streamWriterMock.Verify(a =&gt; a.Write(line), Times.Exactly(1));
  }
  </code></pre>