public void GetDebugInputs_GivenValues_ShouldAddDebugInputs() { //---------------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); dropboxFileListActivityMock.IsFilesSelected = true; dropboxFileListActivityMock.IsRecursive = true; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var mockExecutionEnv = new Mock <IExecutionEnvironment>(); var debugInputs = dropboxFileListActivityMock.GetDebugInputs(mockExecutionEnv.Object, 0); //---------------Test Result ----------------------- Assert.AreEqual(4, debugInputs.Count()); }
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_GivenHasError_ShouldReturnExceptionMessage() { try { //---------------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(TestConstant.ExceptionInstance.Value)); var dropboxFileListActivityMock = new DsfDropboxFileListActivityMock(clientWrapper.Object); dropboxFileListActivityMock.SelectedSource = new DropBoxSource { AccessToken = "Test" }; dropboxFileListActivityMock.DropboxResult = new DropboxFailureResult(TestConstant.ExceptionInstance.Value); dropboxFileListActivityMock.GetDropboxSingleExecutor(mockExecutor.Object); //---------------Assert Precondition---------------- Assert.IsNotNull(dropboxFileListActivityMock); //---------------Execute Test ---------------------- } catch (Exception e) { Assert.AreEqual(TestConstant.ExceptionInstance.Value.Message, e.Message); } //---------------Test Result ----------------------- }