public void GetDropboxClient_GivenClientExists_ShouldReturnExistingClient() { //---------------Set up test pack------------------- var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >(); mockExecutor.Setup(executor => executor.ExecuteTask(TestConstant.DropboxClientInstance.Value)) .Returns(new DropboxListFolderSuccesResult(TestConstant.ListFolderResultInstance.Value)); var dropboxFileListActivityMock = new DsfDropboxFileListActivity(); dropboxFileListActivityMock.GetDropboxSingleExecutor(mockExecutor.Object); dropboxFileListActivityMock.SelectedSource = new DropBoxSource { AccessToken = "Test" }; //---------------Assert Precondition---------------- Assert.IsNotNull(dropboxFileListActivityMock); //---------------Execute Test ---------------------- var dropboxClient = dropboxFileListActivityMock.GetDropboxClient(); var dropboxClient1 = dropboxFileListActivityMock.GetDropboxClient(); //---------------Test Result ----------------------- Assert.IsNotNull(dropboxClient); Assert.IsNotNull(dropboxClient1); Assert.AreEqual(dropboxClient, dropboxClient1); }
public void GivenIDragReadDropboxToolOntoTheDesignSurface() { var mock = new Mock <IServer>(); var mockShellVm = new Mock <IShellViewModel>(); mockShellVm.SetupGet(model => model.ActiveServer).Returns(mock.Object); CustomContainer.Register(mockShellVm.Object); var dropboxFileListActivity = new DsfDropboxFileListActivity(); var modelItem = ModelItemUtils.CreateModelItem(dropboxFileListActivity); var mockEnvironmentRepo = new Mock <IServerRepository>(); var mockEnvironmentModel = new Mock <IServer>(); var mockExecutionEnvironment = new Mock <IExecutionEnvironment>(); var mockResourcRepositorySetUp = new Mock <IResourceRepository>(); var mockEventAggregator = new Mock <IEventAggregator>(); var dropBoxSourceManager = new Mock <IDropboxSourceManager>(); var sources = new List <OauthSource>() { new DropBoxSource() { ResourceName = "Test Resource Name" } }; mockEnvironmentModel.Setup(model => model.IsConnected).Returns(true); mockEnvironmentModel.Setup(model => model.IsLocalHost).Returns(true); mockEnvironmentModel.Setup(model => model.EnvironmentID).Returns(Guid.Empty); mockEnvironmentModel.Setup(model => model.IsLocalHostCheck()).Returns(false); mockResourcRepositorySetUp.Setup(repository => repository.FindSourcesByType <OauthSource>(mockEnvironmentModel.Object, It.IsAny <enSourceType>())) .Returns(sources); mockEnvironmentModel.Setup(model => model.ResourceRepository).Returns(mockResourcRepositorySetUp.Object); mockEnvironmentRepo.Setup(repository => repository.ActiveServer).Returns(mockEnvironmentModel.Object); mockEnvironmentRepo.Setup(repository => repository.FindSingle(It.IsAny <Expression <Func <IServer, bool> > >())).Returns(mockEnvironmentModel.Object); var mockCatalog = new Mock <IResourceCatalog>(); mockCatalog.Setup(catalog => catalog.GetResourceList <Resource>(It.IsAny <Guid>())).Returns(new List <IResource>()); var viewModel = new DropBoxFileListDesignerViewModel(modelItem, dropBoxSourceManager.Object); scenarioContext.Add("viewModel", viewModel); scenarioContext.Add("mockEnvironmentModel", mockEnvironmentModel); scenarioContext.Add("eventAggrMock", mockEventAggregator); }
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 DropboxListFolderSuccesResult(TestConstant.ListFolderResultInstance.Value)); var dropBoxDownloadActivityMock = new DsfDropboxFileListActivity(); dropBoxDownloadActivityMock.GetDropboxSingleExecutor(mockExecutor.Object); //---------------Assert Precondition---------------- Assert.IsNotNull(dropBoxDownloadActivityMock); //---------------Execute Test ---------------------- var executionEnvironment = new Mock <IExecutionEnvironment>().Object; var debugOutputs = dropBoxDownloadActivityMock.GetDebugOutputs(executionEnvironment, 0); //---------------Test Result ----------------------- Assert.AreEqual(0, debugOutputs.Count); }
public void Equals_Given_Different_Object_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var multiAssign = new DsfDropboxFileListActivity() { UniqueID = uniqueId, DisplayName = "A" }; var multiAssign1 = new DsfDropboxFileListActivity() { UniqueID = uniqueId, DisplayName = "ass" }; //---------------Assert Precondition---------------- Assert.IsNotNull(multiAssign); //---------------Execute Test ---------------------- var @equals = multiAssign.Equals(multiAssign1); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void DropBoxSource_Same_Object_Is_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var dropBoxDeleteActivity = new DsfDropboxFileListActivity { UniqueID = uniqueId, Result = "A" }; var dropBoxDeleteActivity1 = new DsfDropboxFileListActivity { UniqueID = uniqueId, Result = "A" }; //---------------Assert Precondition---------------- Assert.IsTrue(dropBoxDeleteActivity.Equals(dropBoxDeleteActivity1)); //---------------Execute Test ---------------------- dropBoxDeleteActivity.SelectedSource = new DropBoxSource(); dropBoxDeleteActivity1.SelectedSource = new DropBoxSource(); var @equals = dropBoxDeleteActivity.Equals(dropBoxDeleteActivity1); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void ToPath_Different_Object_Is_Not_Equal_CaseSensitive() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var multiAssign = new DsfDropboxFileListActivity() { UniqueID = uniqueId, ToPath = "AAA" }; var multiAssign1 = new DsfDropboxFileListActivity() { UniqueID = uniqueId, ToPath = "aaa" }; //---------------Assert DsfDropboxFileListActivity---------------- Assert.IsNotNull(multiAssign); //---------------Execute Test ---------------------- var @equals = multiAssign.Equals(multiAssign1); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void ToPath_Same_Object_IsEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var multiAssign = new DsfDropboxFileListActivity() { UniqueID = uniqueId, ToPath = "a" }; var multiAssign1 = new DsfDropboxFileListActivity() { UniqueID = uniqueId, ToPath = "a" }; //---------------Assert Precondition---------------- Assert.IsNotNull(multiAssign); //---------------Execute Test ---------------------- var @equals = multiAssign.Equals(multiAssign1); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void UniqueIDEquals_EmptyDropBoxDeleteActivities_IsEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var multiAssign = new DsfDropboxFileListActivity() { UniqueID = uniqueId }; var multiAssign1 = new DsfDropboxFileListActivity() { UniqueID = uniqueId }; //---------------Assert Precondition---------------- Assert.IsNotNull(multiAssign); //---------------Execute Test ---------------------- var @equals = multiAssign.Equals(multiAssign1); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void ExecuteTool_GivenNoToPath_ShouldExecuteTool() { //---------------Set up test pack------------------- var mockExecutor = new Mock <IDropboxSingleExecutor <IDropboxResult> >(); mockExecutor.Setup(executor => executor.ExecuteTask(TestConstant.DropboxClientInstance.Value)) .Returns(new DropboxListFolderSuccesResult(TestConstant.ListFolderResultInstance.Value)); var dropboxFileListActivity = new DsfDropboxFileListActivity { ToPath = "" }; dropboxFileListActivity.GetDropboxSingleExecutor(mockExecutor.Object); //---------------Assert Precondition---------------- Assert.IsNotNull(dropboxFileListActivity); //---------------Execute Test ---------------------- var datObj = new Mock <IDSFDataObject>(); var executionEnvironment = new Mock <IExecutionEnvironment>(); datObj.Setup(o => o.Environment).Returns(executionEnvironment.Object); //---------------Test Result ----------------------- }
public void IsFilesAndFoldersSelected_Same_Object_Is_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var rabbitMqActivity = new DsfDropboxFileListActivity() { UniqueID = uniqueId, Result = "A" }; var rabbitMqActivity1 = new DsfDropboxFileListActivity() { UniqueID = uniqueId, Result = "A" }; //---------------Assert Precondition---------------- Assert.IsTrue(rabbitMqActivity.Equals(rabbitMqActivity1)); //---------------Execute Test ---------------------- rabbitMqActivity.IsFilesAndFoldersSelected = true; rabbitMqActivity1.IsFilesAndFoldersSelected = true; var @equals = rabbitMqActivity.Equals(rabbitMqActivity1); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void IncludeDeleted_Different_Object_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var rabbitMqActivity = new DsfDropboxFileListActivity() { UniqueID = uniqueId, Result = "A", }; var rabbitMqActivity1 = new DsfDropboxFileListActivity() { UniqueID = uniqueId, Result = "A" }; //---------------Assert Precondition---------------- Assert.IsTrue(rabbitMqActivity.Equals(rabbitMqActivity1)); //---------------Execute Test ---------------------- rabbitMqActivity.IncludeDeleted = true; rabbitMqActivity1.IncludeDeleted = false; var @equals = rabbitMqActivity.Equals(rabbitMqActivity1); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void DsfDropboxFileListActivity_GetState_ReturnsStateVariable() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid(); var selectedSource = new MockOAuthSource(uniqueId); //------------Setup for test-------------------------- var dropboxFileListActivity = new DsfDropboxFileListActivity { SelectedSource = selectedSource, ToPath = "Path_To", IsFilesSelected = false, IsFoldersSelected = false, IsFilesAndFoldersSelected = false, IsRecursive = false, Result = "List_Complete" }; //------------Execute Test--------------------------- var stateItems = dropboxFileListActivity.GetState(); Assert.AreEqual(7, stateItems.Count()); var expectedResults = new[] { new StateVariable { Name = "SelectedSource.ResourceID", Type = StateVariable.StateType.Input, Value = uniqueId.ToString() }, new StateVariable { Name = "ToPath", Type = StateVariable.StateType.Input, Value = "Path_To" }, new StateVariable { Name = "IsFilesSelected", Type = StateVariable.StateType.Input, Value = "False" }, new StateVariable { Name = "IsFoldersSelected", Type = StateVariable.StateType.Input, Value = "False" }, new StateVariable { Name = "IsFilesAndFoldersSelected", Type = StateVariable.StateType.Input, Value = "False" }, new StateVariable { Name = "IsRecursive", Type = StateVariable.StateType.Input, Value = "False" }, new StateVariable { Name = "Result", Type = StateVariable.StateType.Output, Value = "List_Complete" } }; var iter = dropboxFileListActivity.GetState().Select( (item, index) => new { value = item, expectValue = expectedResults[index] } ); //------------Assert Results------------------------- foreach (var entry in iter) { Assert.AreEqual(entry.expectValue.Name, entry.value.Name); Assert.AreEqual(entry.expectValue.Type, entry.value.Type); Assert.AreEqual(entry.expectValue.Value, entry.value.Value); } }