Exemplo n.º 1
0
        public void GetDebugInputs_GivenValues_ShouldAddDebugInputs()
        {
            //---------------Set up test pack-------------------
            var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >();

            mockExecutor.Setup(executor => executor.ExecuteTask(TestConstant.DropboxClientInstance.Value))
            .Returns(new DropboxUploadSuccessResult(TestConstant.FileMetadataInstance.Value));
            var dropBoxDownloadActivity = new TestDsfDropBoxDownloadActivity {
                FromPath = "File.txt", ToPath = "Test.a"
            };

            dropBoxDownloadActivity.GetDropboxSingleExecutor(mockExecutor.Object);
            dropBoxDownloadActivity.SelectedSource =
                new DropBoxSource
            {
                AccessToken = "Test"
            };
            dropBoxDownloadActivity.GetDropboxSingleExecutor(mockExecutor.Object);
            dropBoxDownloadActivity.OverwriteFile = true;
            dropBoxDownloadActivity.ToPath        = @"C\test.tst";
            dropBoxDownloadActivity.FromPath      = @"C\test.tst";
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var mockExecutionEnv = new Mock <IExecutionEnvironment>();
            var debugInputs      = dropBoxDownloadActivity.GetDebugInputs(mockExecutionEnv.Object, 0);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, debugInputs.Count());
        }
Exemplo n.º 2
0
        public void ExecuteTool_GivenNoToPath_ShouldAddError()
        {
            //---------------Set up test pack-------------------
            var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >();

            mockExecutor.Setup(executor => executor.ExecuteTask(TestConstant.DropboxClientInstance.Value))
            .Returns(new DropboxUploadSuccessResult(TestConstant.FileMetadataInstance.Value));
            var dropBoxDownloadActivity = new TestDsfDropBoxDownloadActivity()
            {
                FromPath = "File.txt"
            };

            dropBoxDownloadActivity.GetDropboxSingleExecutor(mockExecutor.Object);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dropBoxDownloadActivity);
            //---------------Execute Test ----------------------
            var datObj = new Mock <IDSFDataObject>();
            var executionEnvironment = new Mock <IExecutionEnvironment>();

            datObj.Setup(o => o.Environment).Returns(executionEnvironment.Object);

            var dataObject = datObj.Object;

            dropBoxDownloadActivity.Execute(dataObject, 0);
            //---------------Test Result -----------------------
            executionEnvironment.Verify(environment => environment.AddError("Please confirm that the correct file destination has been entered"));
        }
Exemplo n.º 3
0
        public void ExecuteTool_GivenAllPaths_ShouldExecuteTool()
        {
            //---------------Set up test pack-------------------
            var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >();

            mockExecutor.Setup(executor => executor.ExecuteTask(TestConstant.DropboxClientInstance.Value))
            .Returns(new DropboxUploadSuccessResult(TestConstant.FileMetadataInstance.Value));
            var dropBoxDownloadActivity = new TestDsfDropBoxDownloadActivity()
            {
                FromPath = "File.txt", ToPath = "Test.a"
            };

            dropBoxDownloadActivity.GetDropboxSingleExecutor(mockExecutor.Object);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dropBoxDownloadActivity);
            //---------------Execute Test ----------------------
            var datObj = new Mock <IDSFDataObject>();
            var executionEnvironment = new Mock <IExecutionEnvironment>();

            datObj.Setup(o => o.Environment).Returns(executionEnvironment.Object);

            var dataObject   = datObj.Object;
            var dev2Activity = dropBoxDownloadActivity.Execute(dataObject, 0);
            //---------------Test Result -----------------------
        }
Exemplo n.º 4
0
        public void GetDebugOutputs_GivenWebRequestSuccess_ShouldCorrectDebugValue()
        {
            //---------------Set up test pack-------------------
            var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >();

            mockExecutor.Setup(executor => executor.ExecuteTask(TestConstant.DropboxClientInstance.Value))
            .Returns(new DropboxUploadSuccessResult(TestConstant.FileMetadataInstance.Value));
            var dropBoxDownloadActivity = new TestDsfDropBoxDownloadActivity {
                IsUplodValidSuccess = true
            };

            dropBoxDownloadActivity.GetDropboxSingleExecutor(mockExecutor.Object);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dropBoxDownloadActivity);
            //---------------Execute Test ----------------------
            var esbChannel           = new Mock <IEsbChannel>().Object;
            var datObj               = new Mock <IDSFDataObject>().Object;
            var executionEnvironment = new Mock <IExecutionEnvironment>().Object;

            var errorResultTO = new ErrorResultTO();

            dropBoxDownloadActivity.Execute(esbChannel, datObj, String.Empty, String.Empty, out errorResultTO, 0);
            var debugOutputs = dropBoxDownloadActivity.GetDebugOutputs(executionEnvironment, 0);

            //---------------Test Result -----------------------
            Assert.AreEqual(0, debugOutputs.Count);
        }
Exemplo n.º 5
0
        public void PerformExecution_GivenNoPaths_ShouldThrowException()
        {
            //---------------Set up test pack-------------------
            var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >();

            mockExecutor.Setup(executor => executor.ExecuteTask(TestConstant.DropboxClientInstance.Value))
            .Returns(new DropboxDownloadSuccessResult(TestConstant.FileDownloadResponseInstance.Value));
            var dropBoxDownloadActivity = new TestDsfDropBoxDownloadActivity();

            dropBoxDownloadActivity.GetDropboxSingleExecutor(mockExecutor.Object);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dropBoxDownloadActivity);
            //---------------Execute Test ----------------------
            dropBoxDownloadActivity.PerfomBaseExecution(new Dictionary <string, string>()
            {
                { "FromPath", "" },
                { "ToPath", "" }
            });
            //---------------Test Result -----------------------
            Assert.Fail("Exception Not Thrown");
        }