public void PerformExecution_GivenNoToPath_ShouldPassesThrough()
        {
            //---------------Set up test pack-------------------
            var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >();

            mockExecutor.Setup(executor => executor.ExecuteTask(It.IsAny <IDropboxClient>()))
            .Returns(new DropboxFailureResult(new Exception("Test Exception")));
            var mock = new Mock <IDropboxClientFactory>();
            var dropboxFileListActivity = new TestDsfDropboxFileListActivity(mock.Object);

            dropboxFileListActivity.DropboxResult  = new DropboxFailureResult(TestConstant.ExceptionInstance.Value);
            dropboxFileListActivity.SelectedSource =
                new DropBoxSource
            {
                AccessToken = "Test"
            };
            dropboxFileListActivity.GetDropboxSingleExecutor(mockExecutor.Object);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dropboxFileListActivity);
            //---------------Execute Test ----------------------
            dropboxFileListActivity.PerformBaseExecution(new Dictionary <string, string>
            {
            });
            //---------------Test Result -----------------------
            mockExecutor.Verify(executor => executor.ExecuteTask(It.IsAny <IDropboxClient>()));
        }
        public void PerformExecution_GivenPathNotIncludeFolders_ShouldLoadNotLoadFolders()
        {
            //---------------Set up test pack-------------------
            var mockExecutor      = new Mock <IDropboxSingleExecutor <IDropboxResult> >();
            var clientFactoryMock = new Mock <IDropboxClientFactory>();

            mockExecutor.Setup(executor => executor.ExecuteTask(clientFactoryMock.Object.CreateWithSecret("TEST")))
            .Returns(new DropboxListFolderSuccesResult(TestConstant.ListFolderResultInstance.Value));
            var dropboxFileListActivity = new TestDsfDropboxFileListActivity(clientFactoryMock.Object)
            {
                SelectedSource = new DropBoxSource
                {
                    AccessToken = "Test"
                }
            };

            dropboxFileListActivity.DropboxResult = new DropboxListFolderSuccesResult(TestConstant.ListFolderResultInstance.Value);

            //---------------Assert Precondition----------------
            Assert.IsNotNull(dropboxFileListActivity);
            //---------------Execute Test ----------------------
            dropboxFileListActivity.PerformBaseExecution(new Dictionary <string, string>
            {
                { "ToPath", "a.txt" },
                { "IsRecursive", "false" },
                { "IncludeMediaInfo", "false" },
                { "IncludeDeleted", "false" },
                { "IncludeFolders", "false" }
            });
            //---------------Test Result -----------------------
            Assert.AreEqual(0, dropboxFileListActivity.Files.Count());
        }
        public void PerformExecution_GivenHasError_ShouldReturnDropboxFailureResult()
        {
            //---------------Set up test pack-------------------
            var mockExecutor      = new Mock <IDropboxSingleExecutor <IDropboxResult> >();
            var clientFactoryMock = new Mock <IDropboxClientFactory>();

            mockExecutor.Setup(executor => executor.ExecuteTask(clientFactoryMock.Object.CreateWithSecret("TEST")))
            .Returns(new DropboxFailureResult(new Exception("Test Exception")));
            var dropboxFileListActivity = new TestDsfDropboxFileListActivity(clientFactoryMock.Object);

            dropboxFileListActivity.DropboxResult  = new DropboxFailureResult(TestConstant.ExceptionInstance.Value);
            dropboxFileListActivity.SelectedSource =
                new DropBoxSource
            {
                AccessToken = "Test"
            };
            dropboxFileListActivity.GetDropboxSingleExecutor(mockExecutor.Object);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dropboxFileListActivity);
            //---------------Execute Test ----------------------
            dropboxFileListActivity.PerformBaseExecution(new Dictionary <string, string>
            {
                { "ToPath", "@()*&$%" },
                { "IsRecursive", "false" },
                { "IncludeMediaInfo", "false" },
                { "IncludeDeleted", "false" },
                { "IncludeFolders", "false" }
            });
            //---------------Test Result -----------------------
            Assert.Fail("Exception Not Throw");
        }
        public void PerformExecution_GivenPath_ShouldReturnSuccess()
        {
            //---------------Set up test pack-------------------
            var clientFactoryMock = new Mock <IDropboxClientFactory>();

            clientFactoryMock.Setup(o => o.New(It.IsAny <string>(), It.IsAny <HttpClient>())).Returns(new Mock <IDropboxClient>().Object);
            var dropboxFileListActivity = new TestDsfDropboxFileListActivity(clientFactoryMock.Object)
            {
                SelectedSource = new DropBoxSource
                {
                    AccessToken = "Test"
                },
                IsFoldersSelected = true,
            };

            dropboxFileListActivity.DropboxResult = new DropboxListFolderSuccesResult(TestConstant.ListFolderResultInstance.Value);

            //---------------Assert Precondition----------------
            Assert.IsNotNull(dropboxFileListActivity);
            //---------------Execute Test ----------------------
            var execution = dropboxFileListActivity.PerformBaseExecution(new Dictionary <string, string>
            {
                { "ToPath", "a.txt" },
                { "IsRecursive", "false" },
                { "IncludeMediaInfo", "false" },
                { "IncludeDeleted", "false" },
                { "IncludeFolders", "false" }
            });

            //---------------Test Result -----------------------
            Assert.AreEqual(execution, GlobalConstants.DropBoxSuccess);
        }