public void ActivityIOBrokerValidatorDriver_ValidateCopySourceDestinationFileOperation_EnsureFilesDontExists_Overwrite_True_ExpectSuccess()
        {
            //---------------------------Arrange-----------------------------
            var mockActivityIOOperationsEndPointSrc = new Mock <IActivityIOOperationsEndPoint>();
            var mockActivityIOOperationsEndPointDst = new Mock <IActivityIOOperationsEndPoint>();
            var mockDev2CRUDOperationTO             = new Mock <IDev2CRUDOperationTO>();
            var mockActivityIOPathSrc = new Mock <IActivityIOPath>();
            var mockActivityIOPathDst = new Mock <IActivityIOPath>();
            var mockFile   = new Mock <IFile>();
            var mockCommon = new Mock <ICommon>();

            var          srcPath = Path.GetTempPath() + "*";
            const string dstPath = "C:\\Test_TempPath\\";

            mockActivityIOOperationsEndPointSrc.Setup(o => o.IOPath).Returns(mockActivityIOPathSrc.Object);
            mockActivityIOOperationsEndPointDst.Setup(o => o.IOPath).Returns(mockActivityIOPathDst.Object);

            mockActivityIOOperationsEndPointSrc.Setup(o => o.ListFilesInDirectory(mockActivityIOPathSrc.Object)).Returns(new List <IActivityIOPath>());

            mockActivityIOOperationsEndPointDst.Setup(o => o.PathSeperator()).Returns(@"\");

            mockActivityIOPathDst.Setup(o => o.Path).Returns(dstPath);
            mockActivityIOPathSrc.Setup(o => o.Path).Returns(srcPath);

            var list = new List <IActivityIOPath>();

            list.Add(new Dev2ActivityIOPath(enActivityIOPathType.FileSystem, dstPath, null, null, true, null));

            mockActivityIOOperationsEndPointSrc.Setup(o => o.PathIs(It.IsAny <IActivityIOPath>())).Returns(enPathType.File);

            mockActivityIOOperationsEndPointDst.Setup(o => o.PathExist(It.IsAny <IActivityIOPath>())).Returns(true);

            mockCommon.Setup(o => o.ValidateSourceAndDestinationPaths(It.IsAny <IActivityIOOperationsEndPoint>(), It.IsAny <IActivityIOOperationsEndPoint>()));

            mockDev2CRUDOperationTO.Setup(o => o.Overwrite).Returns(true);

            var driver = new ActivityIOBrokerValidatorDriver(mockFile.Object, mockCommon.Object);
            //---------------------------Act---------------------------------
            var fileOperation = driver.ValidateCopySourceDestinationFileOperation(mockActivityIOOperationsEndPointSrc.Object, mockActivityIOOperationsEndPointDst.Object, mockDev2CRUDOperationTO.Object, () => "test func");

            //---------------------------Assert------------------------------
            Assert.AreEqual("Success", fileOperation);
            mockActivityIOOperationsEndPointDst.VerifyAll();
            mockActivityIOOperationsEndPointSrc.VerifyAll();
            mockActivityIOPathSrc.VerifyAll();
            mockActivityIOPathDst.VerifyAll();
            mockDev2CRUDOperationTO.Verify();
            mockCommon.VerifyAll();
        }
        public void ActivityIOBrokerValidatorDriver_ValidateCopySourceDestinationFileOperation_PathIs_Directory_ExpectFail()
        {
            //---------------------------Arrange-----------------------------
            var mockActivityIOOperationsEndPointSrc = new Mock <IActivityIOOperationsEndPoint>();
            var mockActivityIOOperationsEndPointDst = new Mock <IActivityIOOperationsEndPoint>();
            var mockDev2CRUDOperationTO             = new Mock <IDev2CRUDOperationTO>();
            var mockActivityIOPathSrc = new Mock <IActivityIOPath>();
            var mockActivityIOPathDst = new Mock <IActivityIOPath>();
            var mockFile   = new Mock <IFile>();
            var mockCommon = new Mock <ICommon>();

            var          srcPath = Path.GetTempPath();
            const string dstPath = "C:\\Test_TempPath\\";

            mockActivityIOOperationsEndPointSrc.Setup(o => o.IOPath).Returns(mockActivityIOPathSrc.Object);
            mockActivityIOOperationsEndPointDst.Setup(o => o.IOPath).Returns(mockActivityIOPathDst.Object);

            mockActivityIOOperationsEndPointDst.Setup(o => o.PathSeperator()).Returns(@"\");
            mockActivityIOOperationsEndPointDst.Setup(o => o.IOPath).Returns(mockActivityIOPathDst.Object);
            mockActivityIOOperationsEndPointDst.Setup(o => o.CreateDirectory(It.IsAny <IActivityIOPath>(), It.IsAny <IDev2CRUDOperationTO>())).Returns(true);

            mockActivityIOPathSrc.Setup(o => o.Path).Returns(srcPath);
            mockActivityIOPathDst.Setup(o => o.Path).Returns(dstPath);

            mockActivityIOOperationsEndPointSrc.Setup(o => o.PathIs(It.IsAny <IActivityIOPath>())).Returns(enPathType.Directory);
            mockActivityIOOperationsEndPointSrc.Setup(o => o.ListFilesInDirectory(It.IsAny <IActivityIOPath>())).Returns(new List <IActivityIOPath>());
            mockActivityIOOperationsEndPointSrc.Setup(o => o.ListFoldersInDirectory(It.IsAny <IActivityIOPath>())).Returns(new List <IActivityIOPath>());

            mockActivityIOOperationsEndPointDst.Setup(o => o.ListFilesInDirectory(It.IsAny <IActivityIOPath>())).Returns(new List <IActivityIOPath>());

            mockCommon.Setup(o => o.ValidateSourceAndDestinationPaths(It.IsAny <IActivityIOOperationsEndPoint>(), It.IsAny <IActivityIOOperationsEndPoint>()));

            var driver = new ActivityIOBrokerValidatorDriver(mockFile.Object, mockCommon.Object);
            //---------------------------Act---------------------------------
            var fileOperation = driver.ValidateCopySourceDestinationFileOperation(mockActivityIOOperationsEndPointSrc.Object, mockActivityIOOperationsEndPointDst.Object, mockDev2CRUDOperationTO.Object, () => "test func");

            //---------------------------Assert------------------------------
            Assert.AreEqual("Success", fileOperation);
            mockActivityIOPathSrc.VerifyAll();
            mockActivityIOPathDst.VerifyAll();
            mockCommon.VerifyAll();
            mockActivityIOOperationsEndPointDst.VerifyAll();
            mockActivityIOOperationsEndPointSrc.VerifyAll();
        }
        public void ActivityIOBrokerValidatorDriver_ValidateCopySourceDestinationFileOperation_EnsureFilesDontExists_Overwrite_False_PathTypeIsFile_ExpectException()
        {
            //---------------------------Arrange-----------------------------
            var mockActivityIOOperationsEndPointSrc = new Mock <IActivityIOOperationsEndPoint>();
            var mockActivityIOOperationsEndPointDst = new Mock <IActivityIOOperationsEndPoint>();
            var mockDev2CRUDOperationTO             = new Mock <IDev2CRUDOperationTO>();
            var mockActivityIOPathSrc = new Mock <IActivityIOPath>();
            var mockActivityIOPathDst = new Mock <IActivityIOPath>();
            var mockFile   = new Mock <IFile>();
            var mockCommon = new Mock <ICommon>();

            const string dstPath = "C:\\Test_TempPath\\";

            mockActivityIOOperationsEndPointSrc.Setup(o => o.IOPath).Returns(mockActivityIOPathSrc.Object);
            mockActivityIOOperationsEndPointDst.Setup(o => o.IOPath).Returns(mockActivityIOPathDst.Object);

            mockActivityIOOperationsEndPointDst.Setup(o => o.PathSeperator()).Returns(@"\");

            mockActivityIOPathDst.Setup(o => o.Path).Returns(dstPath);

            mockActivityIOOperationsEndPointSrc.Setup(o => o.PathIs(It.IsAny <IActivityIOPath>())).Returns(enPathType.File);

            mockActivityIOOperationsEndPointDst.Setup(o => o.PathExist(It.IsAny <IActivityIOPath>())).Returns(true);

            mockCommon.Setup(o => o.ValidateSourceAndDestinationPaths(It.IsAny <IActivityIOOperationsEndPoint>(), It.IsAny <IActivityIOOperationsEndPoint>()));

            var driver = new ActivityIOBrokerValidatorDriver(mockFile.Object, mockCommon.Object);

            //---------------------------Act---------------------------------
            //---------------------------Assert------------------------------
            Assert.ThrowsException <Exception>(() => driver.ValidateCopySourceDestinationFileOperation(mockActivityIOOperationsEndPointSrc.Object, mockActivityIOOperationsEndPointDst.Object, mockDev2CRUDOperationTO.Object, () => "test func"), "A file with the same name exists on the destination and overwrite is set to false");
            mockActivityIOOperationsEndPointDst.VerifyAll();
            mockActivityIOOperationsEndPointSrc.VerifyAll();
            mockActivityIOPathSrc.VerifyAll();
            mockActivityIOPathDst.VerifyAll();
            mockCommon.VerifyAll();
        }