public void SharepointListDesignerViewModelBase_Constructor_NullModelItem_ThrowsException()
        {
            //------------Setup for test--------------------------


            //------------Execute Test---------------------------
            var sharepointListDesignerViewModelBase = new TestSharepointListDesignerViewModelBase(null, new SynchronousAsyncWorker(), new Mock <IServer>().Object, new Mock <IEventAggregator>().Object, false);

            //------------Assert Results-------------------------
            Assert.IsNull(sharepointListDesignerViewModelBase);
        }
        public void SharepointListDesignerViewModelBase_Constructor_ParametersPassed_ShouldSetupCorrectly()
        {
            //------------Setup for test--------------------------


            //------------Execute Test---------------------------
            var sharepointListDesignerViewModelBase = new TestSharepointListDesignerViewModelBase(CreateModelItem(), new SynchronousAsyncWorker(), new Mock <IServer>().Object, new Mock <IEventAggregator>().Object, false);

            //------------Assert Results-------------------------
            Assert.IsNotNull(sharepointListDesignerViewModelBase);
            Assert.AreEqual(Visibility.Collapsed, sharepointListDesignerViewModelBase.ShowExampleWorkflowLink);
            Assert.IsNotNull(sharepointListDesignerViewModelBase.SharepointServers);
            Assert.IsNotNull(sharepointListDesignerViewModelBase.Lists);
            Assert.IsNotNull(sharepointListDesignerViewModelBase.EditSharepointServerCommand);
            Assert.IsNotNull(sharepointListDesignerViewModelBase.RefreshListsCommand);
            Assert.IsTrue(sharepointListDesignerViewModelBase.RefreshListsCommand.CanExecute(null));
        }
        public void SharepointListDesignerViewModelBase_RemoveFilterItem_ShouldRemoveFromCollection()
        {
            //------------Setup for test--------------------------
            var mockEnvironmentModel = new Mock <IServer>();
            var mockResourceRepo     = new Mock <IResourceRepository>();
            var sharepointSource     = new SharepointSource
            {
                ResourceName = "SharepointServer1",
                ResourceID   = Guid.NewGuid()
            };
            var sharepointSources = new List <SharepointSource> {
                sharepointSource
            };

            mockResourceRepo.Setup(repository => repository.FindSourcesByType <SharepointSource>(It.IsAny <IServer>(), enSourceType.SharepointServerSource)).Returns(sharepointSources);
            var sharepointFieldTos = new List <ISharepointFieldTo>
            {
                new SharepointFieldTo
                {
                    InternalName = "Field 1",
                    IsEditable   = false,
                    Name         = "Name 1",
                    IsRequired   = false,
                    Type         = SharepointFieldType.Text
                }
            };
            var sharepointListTo = new SharepointListTo
            {
                FullName = "Share List",
                Fields   = sharepointFieldTos
            };
            var sharepointListTos = new List <SharepointListTo>
            {
                sharepointListTo
            };

            mockResourceRepo.Setup(repository => repository.GetSharepointLists(It.IsAny <SharepointSource>())).Returns(sharepointListTos);
            mockResourceRepo.Setup(repository => repository.GetSharepointListFields(It.IsAny <ISharepointSource>(), It.IsAny <SharepointListTo>(), false)).Returns(sharepointFieldTos);
            mockEnvironmentModel.Setup(model => model.ResourceRepository).Returns(mockResourceRepo.Object);
            var sharepointReadListTos = new List <SharepointReadListTo>
            {
                new SharepointReadListTo("[[ShareList(*).Name1]]", "Name 1", "Field 1", SharepointFieldType.Text.ToString())
            };
            var modelItem = CreatePopulatedModelItem(sharepointSource.ResourceID, sharepointReadListTos, "Share List");
            var sharepointListDesignerViewModelBase = new TestSharepointListDesignerViewModelBase(modelItem, new SynchronousAsyncWorker(), mockEnvironmentModel.Object, new Mock <IEventAggregator>().Object, false);

            //------------Assert Precondtion---------------------
            Assert.IsNotNull(sharepointListDesignerViewModelBase.SelectedSharepointServer);
            Assert.IsNotNull(sharepointListDesignerViewModelBase.Lists);
            Assert.AreEqual(1, sharepointListDesignerViewModelBase.Lists.Count);
            Assert.IsNotNull(sharepointListDesignerViewModelBase.SelectedList);
            Assert.IsNotNull(sharepointListDesignerViewModelBase.ListItems);
            Assert.AreEqual(1, sharepointListDesignerViewModelBase.ListItems.Count);
            Assert.AreEqual("Name 1", sharepointListDesignerViewModelBase.ListItems[0].FieldName);
            Assert.AreEqual("Field 1", sharepointListDesignerViewModelBase.ListItems[0].InternalName);
            Assert.AreEqual(SharepointFieldType.Text.ToString(), sharepointListDesignerViewModelBase.ListItems[0].Type);
            Assert.IsFalse(sharepointListDesignerViewModelBase.ListItems[0].IsRequired);
            Assert.AreEqual("[[ShareList(*).Name1]]", sharepointListDesignerViewModelBase.ListItems[0].VariableName);
            Assert.AreEqual(2, sharepointListDesignerViewModelBase.ModelItemCollection.Count);
            //------------Execute Test---------------------------
            sharepointListDesignerViewModelBase.RemoveAt(1);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, sharepointListDesignerViewModelBase.ModelItemCollection.Count);
        }