public void ActivityIOBrokerBaseDriver_RemoveAllTmpFiles() { var mockFile = new Mock <IFile>(); var mockCommon = new Mock <ICommon>(); var driver = new ActivityIOBrokerBaseDriver(mockFile.Object, mockCommon.Object); driver.CreateTmpFile(); driver.CreateTmpFile(); driver.RemoveAllTmpFiles(); mockFile.Verify(o => o.Delete(It.IsAny <string>()), Times.Exactly(2)); }
public void ActivityIOBrokerBaseDriver_GetFileNameFromEndPoint_GivenEndPoint_ShouldReturnFileName_Overload() { var driver = new ActivityIOBrokerBaseDriver(); var mockEndpoint = new Mock <IActivityIOOperationsEndPoint>(); var mockActIo = new Mock <IActivityIOPath>(); const string path = "C:\\Home\\txt\\a.srx"; mockActIo.Setup(p => p.Path).Returns(path); mockEndpoint.Setup(point => point.PathSeperator()).Returns(","); mockEndpoint.Setup(point => point.IOPath).Returns(mockActIo.Object); var pathReturned = driver.GetFileNameFromEndPoint(mockEndpoint.Object, mockActIo.Object); Assert.AreEqual(path, pathReturned); }
public void ActivityIOBrokerBaseDriver_CreateDirectory_GivenValidInterfaces_ShouldCallsCreateDirectoryCorrectly() { var dev2CrudOperationTO = new Dev2CRUDOperationTO(true); var endPoint = new Mock <IActivityIOOperationsEndPoint>(); var ioPath = new Mock <IActivityIOPath>().Object; endPoint.Setup(o => o.IOPath).Returns(ioPath); endPoint.Setup(o => o.CreateDirectory(It.IsAny <IActivityIOPath>(), dev2CrudOperationTO)).Returns(true); var driver = new ActivityIOBrokerBaseDriver(); var result = driver.CreateDirectory(endPoint.Object, dev2CrudOperationTO); Assert.IsTrue(result); endPoint.Verify(o => o.CreateDirectory(ioPath, dev2CrudOperationTO)); }
public void ActivityIOBrokerBaseDriver_ListDirectory_FilesAndFolders() { var broker = new ActivityIOBrokerBaseDriver(); var endPoint = new Mock <IActivityIOOperationsEndPoint>(); var ioPath = new Mock <IActivityIOPath>().Object; endPoint.Setup(o => o.IOPath).Returns(ioPath); var mockList = new Mock <IList <IActivityIOPath> >(); endPoint.Setup(point => point.ListDirectory(It.IsAny <IActivityIOPath>())).Returns(mockList.Object); var returnedList = broker.ListDirectory(endPoint.Object, ReadTypes.FilesAndFolders); Assert.AreEqual(0, returnedList.Count); Assert.AreEqual(mockList.Object, returnedList); endPoint.Verify(o => o.ListDirectory(ioPath), Times.Once); }
public void ActivityIOBrokerBaseDriver_CreateEndPoint_IsUncFileTypePath_ExpectFail() { //--------------------------Arrange------------------------- var mockDst = new Mock <IActivityIOOperationsEndPoint>(); var mockArgs = new Mock <IDev2CRUDOperationTO>(); var mockActivityIOPath = new Mock <IActivityIOPath>(); var driver = new ActivityIOBrokerBaseDriver(); mockActivityIOPath.Setup(o => o.Path).Returns(@"\\Home\folder1\folder2\a.txt"); mockDst.Setup(o => o.IOPath).Returns(mockActivityIOPath.Object); mockDst.Setup(o => o.PathSeperator()).Returns(@"\"); //--------------------------Act----------------------------- var endPoint = driver.CreateEndPoint(mockDst.Object, mockArgs.Object, true); //--------------------------Assert-------------------------- Assert.AreEqual("Failure", endPoint); mockDst.VerifyAll(); mockActivityIOPath.VerifyAll(); }
public void ActivityIOBrokerBaseDriver_CreateEndPoint_ExpectSuccess() { //--------------------------Arrange------------------------- var mockActivityIOOperationsEndPoint = new Mock <IActivityIOOperationsEndPoint>(); var mockDev2CRUDOperationTO = new Mock <IDev2CRUDOperationTO>(); var mockActivityIOPath = new Mock <IActivityIOPath>(); var driver = new ActivityIOBrokerBaseDriver(); mockActivityIOOperationsEndPoint.Setup(o => o.IOPath).Returns(mockActivityIOPath.Object); mockActivityIOOperationsEndPoint.Setup(o => o.PathSeperator()).Returns(@"\"); mockActivityIOPath.Setup(o => o.Path).Returns("\\filename.txt"); //--------------------------Act----------------------------- var endPoint = driver.CreateEndPoint(mockActivityIOOperationsEndPoint.Object, mockDev2CRUDOperationTO.Object, true); //--------------------------Assert-------------------------- Assert.AreEqual("Success", endPoint); mockActivityIOOperationsEndPoint.VerifyAll(); mockActivityIOPath.VerifyAll(); }
public void ActivityIOBrokerBaseDriver_CreateEndPoint_IsNotFtpTypePathTest_ExpectSuccess() { //--------------------------Arrange------------------------- var mockActivityIOOperationsEndPoint = new Mock <IActivityIOOperationsEndPoint>(); var mockDev2CRUDOperationTO = new Mock <IDev2CRUDOperationTO>(); var mockActivityIOPath = new Mock <IActivityIOPath>(); var driver = new ActivityIOBrokerBaseDriver(); mockActivityIOOperationsEndPoint.Setup(o => o.IOPath).Returns(mockActivityIOPath.Object); mockActivityIOOperationsEndPoint.Setup(o => o.PathSeperator()).Returns(@"\"); mockActivityIOOperationsEndPoint.Setup(o => o.PathIs(It.IsAny <IActivityIOPath>())).Returns(enPathType.Directory); mockActivityIOPath.Setup(o => o.Path).Returns(@"sftp://Home//a.txt"); //--------------------------Act----------------------------- var endPoint = driver.CreateEndPoint(mockActivityIOOperationsEndPoint.Object, mockDev2CRUDOperationTO.Object, true); //--------------------------Assert-------------------------- Assert.AreEqual("Success", endPoint); mockActivityIOOperationsEndPoint.VerifyAll(); mockActivityIOPath.VerifyAll(); }