public void DropboxFileList_CreateOAuthSource_GivenCanPublish_ShouldResfreshSources() { var agg = new Mock <IEventAggregator>(); var model = CreateModelItem(); var mock = new Mock <IDropboxSourceManager>(); mock.Setup(catalog => catalog.FetchSources <DropBoxSource>()).Returns(new List <DropBoxSource>() { new DropBoxSource(), new DropBoxSource() }); //------------Setup for test-------------------------- // ReSharper disable once UseObjectOrCollectionInitializer var mockVM = new DropBoxFileListDesignerViewModel(model, mock.Object); //---------------Assert Precondition---------------- mockVM.Sources.Clear(); var count = mockVM.Sources.Count(); Assert.AreEqual(0, count); //---------------Execute Test ---------------------- mockVM.Sources = mockVM.LoadOAuthSources(); //---------------Test Result ----------------------- Assert.AreEqual(2, mockVM.Sources.Count); }
private DropBoxFileListDesignerViewModel CreateMockViewModel() { var dropBoxSourceManager = new Mock <IDropboxSourceManager>(); var agg = new Mock <IEventAggregator>(); var dropBoxDownloadViewModel = new DropBoxFileListDesignerViewModel(CreateModelItem(), dropBoxSourceManager.Object); return(dropBoxDownloadViewModel); }
public void DropboxFileList_DropBoxFileListViewModel_GivenIsNew_ShouldReturnInstance() { //---------------Set up test pack------------------- var viewModel = new DropBoxFileListDesignerViewModel(CreateModelItem(), TestResourceCatalog.LazySourceManager.Value); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- //---------------Test Result ----------------------- Assert.IsNotNull(viewModel); }
public void DropboxFileList_downloadViewModel_EditSourceAvailableIfSourceSelected() { var agg = new Mock <IEventAggregator>(); var model = CreateModelItem(); //------------Setup for test-------------------------- var boxUploadViewModel = new DropBoxFileListDesignerViewModel(model, TestResourceCatalog.LazySourceManager.Value); Assert.IsFalse(boxUploadViewModel.IsDropboxSourceSelected); boxUploadViewModel.SelectedSource = new DropBoxSource(); Assert.IsTrue(boxUploadViewModel.IsDropboxSourceSelected); }
public void DropboxFileList_dropBoxFileListViewModel_EditSourceOnlyAvailableIfSourceSelected() { var agg = new Mock <IEventAggregator>(); var sources = GetSources(); var model = CreateModelItem(); //------------Setup for test-------------------------- var dropBoxFileListViewModel = new DropBoxFileListDesignerViewModel(model, TestResourceCatalog.LazySourceManager.Value); Assert.IsFalse(dropBoxFileListViewModel.IsDropboxSourceSelected); dropBoxFileListViewModel.SelectedSource = sources[1] as DropBoxSource; Assert.IsTrue(dropBoxFileListViewModel.IsDropboxSourceSelected); }
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 DropboxFileList_Result_GivenIsSet_ShouldSetModelItemProperty() { var agg = new Mock <IEventAggregator>(); var model = CreateModelItem(); //------------Setup for test-------------------------- // ReSharper disable once UseObjectOrCollectionInitializer var boxUploadViewModel = new DropBoxFileListDesignerViewModel(model, TestResourceCatalog.LazySourceManager.Value); //------------Execute Test--------------------------- boxUploadViewModel.Result = "A"; //------------Assert Results------------------------- ModelProperty property = model.Properties["Result"]; if (property == null) { Assert.Fail("Property Does not exist"); } var modelPropertyValue = property.ComputedValue; Assert.AreEqual("A", modelPropertyValue); }
public void DropboxFileList_IsFilesAndFoldersSelected_GivenIsSet_ShouldSetModelItemProperty() { var agg = new Mock <IEventAggregator>(); var model = CreateModelItem(); //------------Setup for test-------------------------- var dropBoxFileListViewModel = new DropBoxFileListDesignerViewModel(model, TestResourceCatalog.LazySourceManager.Value); //------------Execute Test--------------------------- dropBoxFileListViewModel.IsFilesAndFoldersSelected = true; //------------Assert Results------------------------- var property = model.Properties["IsFilesAndFoldersSelected"]; if (property == null) { Assert.Fail("Property Does not exist"); } var modelPropertyValue = property.ComputedValue; Assert.AreEqual(true, modelPropertyValue); }
public void DropboxFileList_ToPath_GivenIsSet_ShouldSetModelItemProperty() { var agg = new Mock <IEventAggregator>(); var model = CreateModelItem(); //------------Setup for test-------------------------- var boxUploadViewModel = new DropBoxFileListDesignerViewModel(model, TestResourceCatalog.LazySourceManager.Value); //------------Execute Test--------------------------- boxUploadViewModel.ToPath = "A"; //------------Assert Results------------------------- var property = model.Properties["ToPath"]; if (property == null) { Assert.Fail("Property Does not exist"); } var modelPropertyValue = property.ComputedValue; Assert.AreEqual("A", modelPropertyValue); }
public void DropboxFileList_CreateOAuthSource_GivenCanPublish_ShouldPublish() { var agg = new Mock <IEventAggregator>(); agg.Setup(aggregator => aggregator.Publish(It.IsAny <IMessage>())); var model = CreateModelItem(); var shellViewModelMock = new Mock <IShellViewModel>(); shellViewModelMock.Setup(viewModel => viewModel.NewDropboxSource(It.IsAny <string>())); CustomContainer.Register(shellViewModelMock.Object); //------------Setup for test-------------------------- // ReSharper disable once UseObjectOrCollectionInitializer var mockVM = new DropBoxFileListDesignerViewModel(model, TestResourceCatalog.LazySourceManager.Value); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- mockVM.CreateOAuthSource(); //---------------Test Result ----------------------- shellViewModelMock.Verify(viewModel => viewModel.NewDropboxSource(It.IsAny <string>()), Times.Once); }
public void DropboxFileList_dropBoxFileListViewModel_NewSourcePublishesMessage() { var agg = new Mock <IEventAggregator>(); var model = CreateModelItem(); CustomContainer.DeRegister <IShellViewModel>(); var shellViewModelMock = new Mock <IShellViewModel>(); shellViewModelMock.Setup(viewModel => viewModel.NewDropboxSource(It.IsAny <string>())); CustomContainer.Register(shellViewModelMock.Object); //------------Setup for test-------------------------- var dropBoxUploadViewModel = new DropBoxFileListDesignerViewModel(model, TestResourceCatalog.LazySourceManager.Value) { SelectedSource = new DropBoxSource() }; //------------Execute Test--------------------------- dropBoxUploadViewModel.NewSourceCommand.Execute(null); //------------Assert Results------------------------- shellViewModelMock.Verify(viewModel => viewModel.NewDropboxSource(It.IsAny <string>()), Times.Once); CustomContainer.DeRegister <IShellViewModel>(); }
public void DropboxFileList_dropBoxFileListViewModel_EditSourcePublishesMessage() { var agg = new Mock <IEventAggregator>(); var model = CreateModelItem(); var mockShellViewModel = new Mock <IShellViewModel>(); var serverMock = new Mock <IServer>(); mockShellViewModel.Setup(viewModel => viewModel.OpenResource(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <IServer>())); mockShellViewModel.Setup(viewModel => viewModel.ActiveServer).Returns(() => serverMock.Object); CustomContainer.Register(mockShellViewModel.Object); //------------Setup for test-------------------------- var dropBoxFileListViewModel = new DropBoxFileListDesignerViewModel(model, TestResourceCatalog.LazySourceManager.Value) { SelectedSource = new DropBoxSource() }; dropBoxFileListViewModel.EditDropboxSourceCommand.Execute(null); //------------Execute Test--------------------------- //------------Assert Results------------------------- mockShellViewModel.Verify(viewModel => viewModel.OpenResource(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <IServer>())); CustomContainer.DeRegister <IShellViewModel>(); }