public void PerformExecution_GivenHasError_ShouldReturnDropboxFailureResult() { //---------------Set up test pack------------------- var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >(); var clientWrapper = new Mock <IDropboxClientWrapper>(); mockExecutor.Setup(executor => executor.ExecuteTask(clientWrapper.Object)) .Returns(new DropboxFailureResult(new Exception("Test Exception"))); var dropboxFileListActivityMock = new DsfDropboxFileListActivityMock(clientWrapper.Object); dropboxFileListActivityMock.DropboxResult = new DropboxFailureResult(TestConstant.ExceptionInstance.Value); dropboxFileListActivityMock.SelectedSource = new DropBoxSource { AccessToken = "Test" }; dropboxFileListActivityMock.GetDropboxSingleExecutor(mockExecutor.Object); //---------------Assert Precondition---------------- Assert.IsNotNull(dropboxFileListActivityMock); //---------------Execute Test ---------------------- dropboxFileListActivityMock.PerformBaseExecution(new Dictionary <string, string> { { "ToPath", "@()*&$%" }, { "IsRecursive", "false" }, { "IncludeMediaInfo", "false" }, { "IncludeDeleted", "false" }, { "IncludeFolders", "false" } }); //---------------Test Result ----------------------- Assert.Fail("Exception Not Throw"); }
public void PerformExecution_GivenNoToPath_ShouldPassesThrough() { //---------------Set up test pack------------------- var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >(); mockExecutor.Setup(executor => executor.ExecuteTask(It.IsAny <IDropboxClientWrapper>())) .Returns(new DropboxFailureResult(new Exception("Test Exception"))); var mock = new Mock <IDropboxClientWrapper>(); var dropboxFileListActivityMock = new DsfDropboxFileListActivityMock(mock.Object); dropboxFileListActivityMock.DropboxResult = new DropboxFailureResult(TestConstant.ExceptionInstance.Value); dropboxFileListActivityMock.SelectedSource = new DropBoxSource { AccessToken = "Test" }; dropboxFileListActivityMock.GetDropboxSingleExecutor(mockExecutor.Object); //---------------Assert Precondition---------------- Assert.IsNotNull(dropboxFileListActivityMock); //---------------Execute Test ---------------------- dropboxFileListActivityMock.PerformBaseExecution(new Dictionary <string, string> { }); //---------------Test Result ----------------------- mockExecutor.Verify(executor => executor.ExecuteTask(It.IsAny <IDropboxClientWrapper>())); }
public void PerformExecution_GivenPathNotIncludeFolders_ShouldLoadNotLoadFolders() { //---------------Set up test pack------------------- var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >(); var clientWrapper = new Mock <IDropboxClientWrapper>(); mockExecutor.Setup(executor => executor.ExecuteTask(clientWrapper.Object)) .Returns(new DropboxListFolderSuccesResult(TestConstant.ListFolderResultInstance.Value)); var dropboxFileListActivityMock = new DsfDropboxFileListActivityMock(clientWrapper.Object) { SelectedSource = new DropBoxSource { AccessToken = "Test" } }; dropboxFileListActivityMock.DropboxResult = new DropboxListFolderSuccesResult(TestConstant.ListFolderResultInstance.Value); //---------------Assert Precondition---------------- Assert.IsNotNull(dropboxFileListActivityMock); //---------------Execute Test ---------------------- dropboxFileListActivityMock.PerformBaseExecution(new Dictionary <string, string> { { "ToPath", "a.txt" }, { "IsRecursive", "false" }, { "IncludeMediaInfo", "false" }, { "IncludeDeleted", "false" }, { "IncludeFolders", "false" } }); //---------------Test Result ----------------------- Assert.AreEqual(0, dropboxFileListActivityMock.Files.Count()); }