Exemplo n.º 1
0
        public SimSPView SetView()
        {
            var view = new SimSPView();

            this.View = view.Instance;
            return(view);
        }
        public SimSPView SetOne()
        {
            var view = new SimSPView
            {
                ParentList = this.List
            };

            base.Clear();
            base.Add(view.Instance);

            return(view);
        }
Exemplo n.º 3
0
        private SimSPView GetOrCreateDefaultView()
        {
            var view = SimSPView.FromInstance(this.views.DefaultView);

            if (view == null)
            {
                view = this.views.SetOne();
                this.views.DefaultViewIndex = 0;
                view.Title = "Default View";
            }

            return(view);
        }
Exemplo n.º 4
0
        protected SimSPList(SPList instance)
            : base(instance)
        {
            this.contentTypes      = new SimSPContentTypeCollection();
            this.fields            = new SimSPFieldCollection();
            this.fieldIndexes      = new SimSPFieldIndexCollection();
            this.items             = new SimSPListItemCollection();
            this.views             = new SimSPViewCollection();
            this.contentTypes.List = this.Instance;
            this.fields.List       = this.Instance;
            this.fieldIndexes.List = this.Instance;
            this.items.List        = this.Instance;
            this.views.List        = this.Instance;
            this.GetOrCreateDefaultView();

            var shimSPList = new ShimSPList(instance);

            shimSPList.IDGet            = () => this.ID;
            shimSPList.HiddenGet        = () => this.Hidden;
            shimSPList.HiddenSetBoolean = (bool value) =>
            {
                this.Hidden = value;
            };
            shimSPList.EnableAttachmentsGet        = () => this.EnableAttachments;
            shimSPList.EnableAttachmentsSetBoolean = (bool value) =>
            {
                this.EnableAttachments = value;
            };
            shimSPList.TitleGet       = () => this.Title;
            shimSPList.TitleSetString = (string newTitle) =>
            {
                this.Title = newTitle;
            };
            shimSPList.RootFolderGet     = () => this.RootFolder;
            shimSPList.RootFolderUrlGet  = () => this.RootFolderUrl;
            shimSPList.DefaultViewGet    = () => this.GetOrCreateDefaultView().Instance;
            shimSPList.DefaultViewUrlGet = () =>
            {
                SimSPView orCreateDefaultView = this.GetOrCreateDefaultView();
                return(orCreateDefaultView.ServerRelativeUrl);
            };
            shimSPList.ParentWebGet     = () => this.ParentWeb;
            shimSPList.Delete           = new FakesDelegates.Action(this.Delete);
            shimSPList.ListsGet         = () => this.Lists;
            shimSPList.ItemsGet         = () => this.items.Instance;
            shimSPList.FieldsGet        = () => this.fields.Instance;
            shimSPList.FieldIndexesGet  = () => this.fieldIndexes.Instance;
            shimSPList.ContentTypesGet  = () => this.contentTypes.Instance;
            shimSPList.ViewsGet         = () => this.views.Instance;
            shimSPList.GetItemByIdInt32 = (int id) =>
            {
                foreach (SPListItem current in this.items)
                {
                    if (current.ID == id)
                    {
                        return(current);
                    }
                }
                throw new ArgumentException();
            };
            shimSPList.GetItemsSPView = (SPView view) => this.GetItems().Instance;
            shimSPList.ItemCountGet   = () => this.Items.Count;
            shimSPList.Update         = () =>
            {
                this.Updated = new bool?(false);
            };
            shimSPList.UpdateBoolean = (bool fromMigration) =>
            {
                this.Updated = new bool?(fromMigration);
            };
            shimSPList.AddItem = () => this.AddItem();
            shimSPList.ContentTypesEnabledGet        = () => this.ContentTypesEnabled;
            shimSPList.ContentTypesEnabledSetBoolean = (bool value) =>
            {
                this.ContentTypesEnabled = value;
            };
            this.Fake = shimSPList;
        }