public void ReadProperlyFile_Test() { // Arrange ArrangeMocks(); _fileReader = MockRepository.GenerateMock<IFileReader>(); var service = new ScanningService(_lineProcessor, _dataAccess, _fileReader); var actualPath = string.Empty; _fileReader.Expect(x => x.ReadByLine(Arg<string>.Is.Anything)).Return(_lines).WhenCalled(x => { actualPath = (string)x.Arguments[0]; }); // Act var actualResult = service.AddScanningFile(_testPath, _token); actualResult.Wait(_token); // Assert _fileReader.VerifyAllExpectations(); Assert.AreEqual(_testPath, actualPath); }