Exemplo n.º 1
0
 public void MainViewModel_ShowOAuthSave_ShowsDialog_AndSave()
 {
     //------------Setup for test--------------------------
     var localhost = new Mock<IEnvironmentModel>();
     localhost.Setup(e => e.ID).Returns(Guid.Empty);
     localhost.Setup(e => e.IsConnected).Returns(true);
     var environmentRepository = new Mock<IEnvironmentRepository>();
     environmentRepository.Setup(c => c.All()).Returns(new[] { localhost.Object });
     environmentRepository.Setup(c => c.Source).Returns(localhost.Object);
     var eventPublisher = new Mock<IEventAggregator>();
     var asyncWorker = AsyncWorkerTests.CreateSynchronousAsyncWorker();
     var resourceRep = new Mock<IResourceRepository>();
     var versionChecker = new Mock<IVersionChecker>();
     var browserPopupController = new Mock<IBrowserPopupController>();
     var viewModel = new MainViewModelMock(eventPublisher.Object, asyncWorker.Object, environmentRepository.Object, versionChecker.Object, new Mock<IStudioResourceRepository>().Object, new Mock<IConnectControlSingleton>().Object, new Mock<IConnectControlViewModel>().Object, false, browserPopupController.Object) { IsBusyDownloadingInstaller = () => false };
     //------------Execute Test---------------------------
     bool save = false;
     bool drop = false;
     var newEnvironment = new Mock<IEnvironmentModel>();
     viewModel.SetActiveEnvironment(newEnvironment.Object);
     newEnvironment.Setup(a => a.ResourceRepository).Returns(resourceRep.Object);
     viewModel.ShowSaveDialog = (a, b, c, d) => save = true;
     viewModel.ShowDropboxAction = (window, vm) => { vm.HasAuthenticated = true; drop = true; return true; };
     viewModel.CreateOAuthType(newEnvironment.Object, "DropboxSource", "bob", false);
     //------------Assert Results-------------------------
     Assert.IsTrue(save);
     Assert.IsTrue(drop);
 }
Exemplo n.º 2
0
 public void MainViewModel_SetActiveEnvironment_ActiveEnvironmentIsUpdated()
 {
     //------------Setup for test--------------------------
     var localhost = new Mock<IEnvironmentModel>();
     localhost.Setup(e => e.ID).Returns(Guid.Empty);
     localhost.Setup(e => e.IsConnected).Returns(true);
     var environmentRepository = new Mock<IEnvironmentRepository>();
     environmentRepository.Setup(c => c.All()).Returns(new[] { localhost.Object });
     environmentRepository.Setup(c => c.Source).Returns(localhost.Object);
     var eventPublisher = new Mock<IEventAggregator>();
     var asyncWorker = AsyncWorkerTests.CreateSynchronousAsyncWorker();
     var versionChecker = new Mock<IVersionChecker>();
     var browserPopupController = new Mock<IBrowserPopupController>();
     var viewModel = new MainViewModelMock(eventPublisher.Object, asyncWorker.Object, environmentRepository.Object, versionChecker.Object, new Mock<IStudioResourceRepository>().Object, new Mock<IConnectControlSingleton>().Object, new Mock<IConnectControlViewModel>().Object, false, browserPopupController.Object) { IsBusyDownloadingInstaller = () => false };
     //------------Execute Test---------------------------
     var newEnvironment = new Mock<IEnvironmentModel>();
     viewModel.SetActiveEnvironment(newEnvironment.Object);
     //------------Assert Results-------------------------
     Assert.AreEqual(newEnvironment, viewModel.ActiveEnvironment);
 }