public void TestCsv() { CSVFormatter t = new CSVFormatter(_dataServiceMock.Object); var dummyItems = DataService.CreateDummyItems(); _dataServiceMock.Setup(d => d.ReadData()).Returns(dummyItems); t.Execute(); _dataServiceMock.Verify(d => d.OpenConnection(), Times.Once); string expectedText = getExpectedFormat(); _dataServiceMock.Verify(d => d.ExportData(expectedText), Times.Once); _dataServiceMock.Verify(d => d.CloseConnection(), Times.Once); }