public void Dev2FTPProvider_Get_ExpectedException() { const string path = "path"; var filesToCleanup = new List <string>(); var mockActivityIOPath = new Mock <IActivityIOPath>(); mockActivityIOPath.Setup(activityIOPath => activityIOPath.Path).Returns(path); var dev2FTPProvider = new Dev2FTPProvider(null); try { dev2FTPProvider.Get(mockActivityIOPath.Object, filesToCleanup); Assert.Fail("Code should have caused an exception to be thrown"); } catch (Exception ex) { Assert.AreEqual("Object reference not set to an instance of an object. , [path]", ex.Message); } }
public void Dev2FTPProvider_Get_IsStandardFtp_ReadFromSftp() { var mockActivityIOPath = new Mock <IActivityIOPath>(); mockActivityIOPath.Setup(activityIOPath => activityIOPath.PathType).Returns(Interfaces.Enums.enActivityIOPathType.FileSystem); Stream streamResult = new MemoryStream(new byte[0]); Stream streamNullResult = null; var filesToCleanup = new List <string>(); var mockImplementation = new Mock <IImplementation>(); mockImplementation.Setup(implementation => implementation.IsStandardFtp(mockActivityIOPath.Object)).Returns(false); mockImplementation.Setup(implementation => implementation.ReadFromSftp(mockActivityIOPath.Object, ref streamResult, filesToCleanup)); var dev2FTPProvider = new Dev2FTPProvider(mockImplementation.Object); var stream = dev2FTPProvider.Get(mockActivityIOPath.Object, filesToCleanup); Assert.AreEqual(null, stream); mockImplementation.Verify(implementation => implementation.IsStandardFtp(mockActivityIOPath.Object), Times.Once); mockImplementation.Verify(implementation => implementation.ReadFromSftp(mockActivityIOPath.Object, ref streamNullResult, filesToCleanup), Times.Once); }