Ejemplo n.º 1
0
        public void ExtractFile_GivenGivenValidArgs_ShouldNotThrowExc()
        {
            //---------------Set up test pack-------------------
            var tempFileName = Path.GetTempFileName();
            var tempPath     = Path.GetDirectoryName(tempFileName);
            Dev2UnZipOperationTO operationTO = new Dev2UnZipOperationTO("Password", false);
            ZipFile file = new ZipFile();

            file.AddFile(tempFileName);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                Util.CommonDataUtils commonDataUtils = new Util.CommonDataUtils();
                file.Save(tempFileName);
                commonDataUtils.ExtractFile(operationTO, file, tempPath);
            }
            catch (Exception ex)
            {
                Assert.AreEqual("", ex.Message);
            }
            finally
            {
                File.Delete(tempFileName);
            }

            //---------------Test Result -----------------------
        }
Ejemplo n.º 2
0
        public void ExtractZipCompressionLevel_GivenLevel_ShouldCorreclty()
        {
            //---------------Set up test pack-------------------
            Util.CommonDataUtils commonDataUtils = new Util.CommonDataUtils();
            var level = commonDataUtils.ExtractZipCompressionLevel("Test");

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsNotNull(level);
            Assert.AreEqual(CompressionLevel.Default, level);
        }
Ejemplo n.º 3
0
        public void IsUncFileTypePath_GivenUNCPath_ShouldReturnTrue()
        {
            //---------------Set up test pack-------------------
            const string txt      = "\\\\Home\\a.txt";
            var          pathMock = new Mock <IActivityIOPath>();

            pathMock.Setup(path => path.Path).Returns(txt);
            Util.CommonDataUtils commonDataUtils = new Util.CommonDataUtils();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var value = commonDataUtils.IsUncFileTypePath(pathMock.Object);

            //---------------Test Result -----------------------
            Assert.IsTrue(bool.Parse(value.ToString()));
        }
Ejemplo n.º 4
0
        public void AppendToTemp_GivenStreamAndTempString_ShouldNotThroException()
        {
            //---------------Set up test pack-------------------
            var          activityOperationsBroker = CreateBroker();
            var          commonDataUtils          = new Util.CommonDataUtils();
            const string dispatcherInvoke         = "Dispatcher.Invoke";
            Stream       stream    = new MemoryStream(Encoding.ASCII.GetBytes(dispatcherInvoke));
            const string ranString = "Rando.net";

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            commonDataUtils.AppendToTemp(stream, ranString);

            //---------------Test Result -----------------------
        }
Ejemplo n.º 5
0
        public void CreateTmpDirectory_GivenObject_ShouldCreateFolderInTheCorrectLocation()
        {
            //---------------Set up test pack-------------------
            var activityOperationsBroker = CreateBroker();
            var privateObject            = new PrivateObject(activityOperationsBroker);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var commonDataUtils = new Util.CommonDataUtils();
            var path            = commonDataUtils.CreateTmpDirectory();

            //---------------Test Result -----------------------
            Assert.IsNotNull(path);
            Assert.IsTrue(Directory.Exists(path));
            StringAssert.Contains(path, GlobalConstants.TempLocation);
        }
Ejemplo n.º 6
0
        public void ValidateEndPoint_GivenEmptyPath_ShouldThrowValidExc()
        {
            //---------------Set up test pack-------------------
            var dev2CrudOperationTO = new Dev2CRUDOperationTO(true);
            var endPoint            = new Mock <IActivityIOOperationsEndPoint>();

            endPoint.Setup(point => point.IOPath.Path).Returns("");
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                Util.CommonDataUtils commonDataUtils = new Util.CommonDataUtils();
                commonDataUtils.ValidateEndPoint(endPoint.Object, dev2CrudOperationTO);
            }
            catch (Exception e)
            {
                Assert.AreEqual(ErrorResource.SourceCannotBeAnEmptyString, e.Message);
            }
            //---------------Test Result -----------------------
        }
Ejemplo n.º 7
0
        public void ValidateEndPoint_GivenPathAndOverwriteFalse_ShouldThrowValidExc()
        {
            //---------------Set up test pack-------------------
            var activityOperationsBroker = CreateBroker();
            var dev2CrudOperationTO      = new Dev2CRUDOperationTO(false);
            var endPoint = new Mock <IActivityIOOperationsEndPoint>();

            endPoint.Setup(point => point.IOPath.Path).Returns("somepath");
            endPoint.Setup(point => point.PathExist(It.IsAny <IActivityIOPath>())).Returns(true);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                Dev2.Data.Util.CommonDataUtils commonDataUtils = new Util.CommonDataUtils();
                commonDataUtils.ValidateEndPoint(endPoint.Object, dev2CrudOperationTO);
            }
            catch (Exception e)
            {
                Assert.AreEqual(ErrorResource.DestinationDirectoryExist, e.Message);
            }
            //---------------Test Result -----------------------
        }