示例#1
0
        private DropBoxDeleteViewModel CreateMockViewModel()
        {
            var dropBoxSourceManager = new Mock <IDropboxSourceManager>();
            var agg = new Mock <IEventAggregator>();
            var dropBoxDeleteViewModel = new DropBoxDeleteViewModel(CreateModelItem(), dropBoxSourceManager.Object);

            return(dropBoxDeleteViewModel);
        }
示例#2
0
        public void DropBoxDeleteViewModel_Sources_EditSource_AvailableIfSourceSelected()
        {
            //------------Setup for test--------------------------
            var agg   = new Mock <IEventAggregator>();
            var model = CreateModelItem();
            //------------Execute Test---------------------------
            var dropBoxDeleteViewModel = new DropBoxDeleteViewModel(model, TestResourceCatalog.LazySourceManager.Value);

            //------------Assert Results-------------------------
            Assert.IsFalse(dropBoxDeleteViewModel.IsDropboxSourceSelected);
            dropBoxDeleteViewModel.SelectedSource = new DropBoxSource();
            Assert.IsTrue(dropBoxDeleteViewModel.IsDropboxSourceSelected);
        }
示例#3
0
        public void DropBoxDeleteViewModel_Result_GivenIsSet_ShouldSetModelItemProperty()
        {
            //------------Setup for test--------------------------
            var agg   = new Mock <IEventAggregator>();
            var model = CreateModelItem();
            //------------Execute Test---------------------------
            // ReSharper disable once UseObjectOrCollectionInitializer
            var dropBoxDeleteViewModel = new DropBoxDeleteViewModel(model, TestResourceCatalog.LazySourceManager.Value);

            dropBoxDeleteViewModel.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);
        }
示例#4
0
        public void DropBoxDeleteViewModel_CreateOAuthSource_GivenCanPublish_ShouldResfreshSources()
        {
            //------------Setup for test--------------------------
            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()
            });
            //------------Execute Test---------------------------
            var mockVM = new DropBoxDeleteViewModel(model, mock.Object);

            mockVM.Sources.Clear();
            var count = mockVM.Sources.Count();

            //------------Assert Results-------------------------
            Assert.AreEqual(0, count);

            mockVM.Sources = mockVM.LoadOAuthSources();
            Assert.AreEqual(2, mockVM.Sources.Count);
        }
示例#5
0
        public void DropBoxDeleteViewModel_Sources_EditSource_PublishesMessage()
        {
            //------------Setup for test--------------------------

            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);
            //------------Execute Test---------------------------
            var dropBoxDeleteViewModel = new DropBoxDeleteViewModel(model, TestResourceCatalog.LazySourceManager.Value)
            {
                SelectedSource = new DropBoxSource()
            };

            dropBoxDeleteViewModel.EditDropboxSourceCommand.Execute(null);
            //------------Assert Results-------------------------
            mockShellViewModel.Verify(viewModel => viewModel.OpenResource(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <IServer>()));
            CustomContainer.DeRegister <IShellViewModel>();
        }
示例#6
0
        public void DropBoxDeleteViewModel_DeletePath_GivenIsSet_ShouldSetModelItemProperty()
        {
            //------------Setup for test--------------------------
            var agg   = new Mock <IEventAggregator>();
            var model = CreateModelItem();

            //------------Execute Test---------------------------

            var dropBoxDeleteViewModel = new DropBoxDeleteViewModel(model, TestResourceCatalog.LazySourceManager.Value);

            dropBoxDeleteViewModel.DeletePath = "A";

            //------------Assert Results-------------------------
            var property = model.Properties["DeletePath"];

            if (property == null)
            {
                Assert.Fail("Property Does not exist");
            }
            var modelPropertyValue = property.ComputedValue;

            Assert.AreEqual("A", modelPropertyValue);
        }
示例#7
0
        public void GivenIDragDeleteDropboxToolOntoTheDesignSurface()
        {
            var dropBoxDeleteTool          = new DsfDropBoxDeleteActivity();
            var modelItem                  = ModelItemUtils.CreateModelItem(dropBoxDeleteTool);
            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 mock = new Mock <IResourceCatalog>();

            mock.Setup(catalog => catalog.GetResourceList <Resource>(It.IsAny <Guid>())).Returns(new List <IResource>());
            var deleteViewModel = new DropBoxDeleteViewModel(modelItem, dropBoxSourceManager.Object);

            scenarioContext.Add("deleteViewModel", deleteViewModel);
            scenarioContext.Add("mockEnvironmentModel", mockEnvironmentModel);
            scenarioContext.Add("mockEventAggregator", mockEventAggregator.Object);
        }