Пример #1
0
        public SimWeb(Web instance)
            : base(instance)
        {
            _lists = new SimListCollection();
            _webs  = new SimWebCollection(this);

            this.Fake.IdGet  = (() => this.ID);
            this.Fake.UrlGet = (() => this.Url);
            this.Fake.ServerRelativeUrlGet       = () => this.ServerRelativeUrl;
            this.Fake.ServerRelativeUrlSetString = (s) => this.ServerRelativeUrl = s;
            this.Fake.TitleGet             = (() => this.Title);
            this.Fake.TitleSetString       = ((s) => this._title = s);
            this.Fake.DescriptionGet       = () => this.Description;
            this.Fake.DescriptionSetString = (s) => this.Description = s;
            this.Fake.Update         = () => { };
            this.Fake.ListsGet       = () => _lists.Instance;
            this.Fake.WebsGet        = () => _webs.Instance;
            this.Fake.DeleteObject   = () => { };
            this.Fake.CurrentUserGet = () => this.CurrentUser.Instance;

            this.Site        = new ShimSite();
            this.CurrentUser = new SimUser();
        }
Пример #2
0
        internal SimSite(Site instance, Uri siteUrl)
            : base(instance)
        {
            Fake.AllowCreateDeclarativeWorkflowGet        = () => AllowCreateDeclarativeWorkflow;
            Fake.AllowCreateDeclarativeWorkflowSetBoolean = (b) => AllowCreateDeclarativeWorkflow = b;
            Fake.AllowDesignerGet                                 = () => AllowDesigner;
            Fake.AllowDesignerSetBoolean                          = (b) => AllowDesigner = b;
            Fake.AllowMasterPageEditingGet                        = () => AllowMasterPageEditing;
            Fake.AllowMasterPageEditingSetBoolean                 = (b) => AllowMasterPageEditing = b;
            Fake.AllowRevertFromTemplateGet                       = () => AllowRevertFromTemplate;
            Fake.AllowRevertFromTemplateSetBoolean                = (b) => AllowRevertFromTemplate = b;
            Fake.AllowSaveDeclarativeWorkflowAsTemplateGet        = () => AllowSaveDeclarativeWorkflowAsTemplate;
            Fake.AllowSaveDeclarativeWorkflowAsTemplateSetBoolean = (b) => AllowSaveDeclarativeWorkflowAsTemplate = b;
            Fake.AllowSavePublishDeclarativeWorkflowGet           = () => AllowSavePublishDeclarativeWorkflow;
            Fake.AllowSavePublishDeclarativeWorkflowSetBoolean    = (b) => AllowSavePublishDeclarativeWorkflow = b;
            Fake.AllowSelfServiceUpgradeEvaluationGet             = () => AllowSelfServiceUpgradeEvaluation;
            Fake.AllowSelfServiceUpgradeEvaluationSetBoolean      = (b) => AllowSelfServiceUpgradeEvaluation = b;
            Fake.AllowSelfServiceUpgradeGet                       = () => AllowSelfServiceUpgrade;
            Fake.AllowSelfServiceUpgradeSetBoolean                = (b) => AllowSelfServiceUpgrade = b;
            Fake.AuditGet = () => this.Audit;
            Fake.AuditLogTrimmingRetentionGet      = () => AuditLogTrimmingRetention;
            Fake.AuditLogTrimmingRetentionSetInt32 = (i) => AuditLogTrimmingRetention = i;
            Fake.CanUpgradeGet         = () => CanUpgrade;
            Fake.CompatibilityLevelGet = () => CompatibilityLevel;
            Fake.EventReceiversGet     = () => this.EventReceivers;
            Fake.FeaturesGet           = () => this.Features;
            Fake.GetCatalogInt32       = (typeCatalog) => this.GetCatalog(typeCatalog);
            Fake.IdGet           = () => Id;
            Fake.OpenWebByIdGuid = (id) =>
            {
                return(OpenWeb((w) => w.Id == id));
            };
            Fake.OpenWebString = (url) =>
            {
                return(OpenWeb((w) => w.Url == url));
            };
            Fake.OwnerGet      = () => Owner;
            Fake.OwnerSetUser  = (u) => this.Owner = u;
            Fake.PrimaryUriGet = () => PrimaryUri;
            Fake.RootWebGet    = () => RootWeb.Instance;
            //Fake.ServerRelativeUrlGet = () => ServerRelativeUrl;
            //Fake.UrlGet = () => Url;
            Fake.UserCustomActionsGet = () => UserCustomActions;

            this.CurrentWeb = new SimWeb
            {
                Site              = Fake,
                Title             = "Team Site",
                Url               = siteUrl.AbsoluteUri.TrimEnd('/'),
                ServerRelativeUrl = siteUrl.AbsolutePath
            };
            _webs = new SimWebCollection(CurrentWeb);
            _webs.Add(CurrentWeb.Instance);

            if (UrlUtility.IsUrlRootWeb(siteUrl))
            {
                this.RootWeb = CurrentWeb;
            }
            else
            {
                var rootUrl = UrlUtility.GetRootWebUri(siteUrl);
                this.RootWeb = new SimWeb
                {
                    Site              = Fake,
                    Title             = "Team Site",
                    Url               = rootUrl.AbsoluteUri.TrimEnd('/'),
                    ServerRelativeUrl = rootUrl.AbsolutePath
                };

                _webs.Add(RootWeb.Instance);
            }
        }