public void ctor_ValidStackBuilt()
        {
            //Arrange
            BSPSite site = new BSPSite();
            BSPWeb  web  = site.SetRootWeb();

            web.ServerRelativeUrl = "foo/bar";
            BSPList list = web.Lists.SetOne();

            list.Title = ConfigurationList.ConfigListName;
            web.ID     = TestsConstants.TestGuid;
            site.ID    = new Guid("{7C039254-10B7-49F0-AA8D-F592206C7130}");
            var moleWeb = new Microsoft.SharePoint.Moles.MSPWeb(web);

            moleWeb.GetListString = (listUrl) =>
            {
                if (listUrl == "foo/bar/Lists/" + ConfigurationList.ConfigListName)
                {
                    return(list);
                }
                return(null);
            };

            //Act
            var stack = new SandboxWithProxyPropertyBagHierarchy(web);

            //Assert
            Assert.IsTrue(stack.PropertyBags.Count() == 4);
            Assert.IsInstanceOfType(stack.PropertyBags.First(), typeof(SPWebPropertyBag));
            Assert.IsInstanceOfType(stack.PropertyBags.Skip(1).First(), typeof(SPSitePropertyBag));
            Assert.IsInstanceOfType(stack.PropertyBags.Skip(2).First(), typeof(SandboxWebAppPropertyBag));
            Assert.IsInstanceOfType(stack.PropertyBags.Skip(3).First(), typeof(SandboxFarmPropertyBag));
        }
コード例 #2
0
        public void Execute_TracesMessage()
        {
            //Arrange
            var  args       = new TracingOperationArgs();
            Guid createGuid = Guid.Empty;

            args.Message  = TestsConstants.TestGuidName;
            args.EventId  = -99;
            args.Category = TestsConstants.AreasCategories;
            args.Severity = (int)SandboxTraceSeverity.High;
            args.SiteID   = TestsConstants.TestGuid;

            SharePointServiceLocator.ReplaceCurrentServiceLocator(new ActivatingServiceLocator());
            ((ActivatingServiceLocator)SharePointServiceLocator.GetCurrent())
            .RegisterTypeMapping <ILogger, TestTraceLogger>(InstantiationType.AsSingleton);

            var operation = new TracingOperation();

            BSPFarm.SetLocal();
            MSPSite site;
            BSPWeb  bweb = new BSPWeb();
            var     mweb = new MSPWeb(bweb)
            {
                NameGet = () => "foo.bar",
            };


            MSPSite.ConstructorGuid = (instance, g) =>
            {
                site = new MSPSite(instance)
                {
                    Dispose    = () => { },
                    IDGet      = () => TestsConstants.TestGuid,
                    RootWebGet = () => mweb
                };

                createGuid = g;
            };


            //Act
            object target = operation.Execute(args);

            //Assert
            var logger = SharePointServiceLocator.GetCurrent().GetInstance <ILogger>() as TestTraceLogger;

            Assert.IsNotInstanceOfType(target, typeof(Exception));
            Assert.AreEqual(TestsConstants.TestGuid, createGuid);
            Assert.IsTrue(logger.Message.Contains(args.Message));
            Assert.AreEqual(logger.Category, TestsConstants.AreasCategories);
            Assert.AreEqual(logger.EventId, args.EventId);
            Assert.AreEqual(logger.Severity, SandboxTraceSeverity.High);
        }
        public void ctor_ValidStackBuilt()
        {
            //Arrange
            var    site = new BSPSite();
            BSPWeb web  = site.SetRootWeb();

            web.Site = site;
            var webApp = new BSPWebApplication();

            site.WebApplication = webApp;
            var f = new BSPConfiguredFarm();

            webApp.Farm = SPFarm.Local;

            //Act
            var stack = new FullTrustPropertyBagHierarchy(web);

            //Assert
            Assert.IsTrue(stack.PropertyBags.Count() == 4);
            Assert.IsInstanceOfType(stack.PropertyBags.First(), typeof(SPWebPropertyBag));
            Assert.IsInstanceOfType(stack.PropertyBags.Skip(1).First(), typeof(SPSitePropertyBag));
            Assert.IsInstanceOfType(stack.PropertyBags.Skip(2).First(), typeof(SPWebAppPropertyBag));
            Assert.IsInstanceOfType(stack.PropertyBags.Skip(3).First(), typeof(SPFarmPropertyBag));
        }
コード例 #4
0
        public void GetHierarchy_GetsHierarchyForSandbox_WithProxyInstalled()
        {
            //Arrange
            var context = new MockAppContextProvider();

            context.AddProxyType(ProxyArgs.ReadConfigArgs.OperationTypeName);
            context.AddProxyType(ProxyArgs.ProxyInstalledArgs.OperationTypeName);
            context.SetSandbox();
            SharePointEnvironment.ApplicationContextProvider = context;
            var    site = new BSPSite();
            BSPWeb web  = site.SetRootWeb();

            web.ServerRelativeUrl = "foo/bar";

            BSPList list = web.Lists.SetOne();

            list.Title = ConfigurationList.ConfigListName;
            web.ID     = TestsConstants.TestGuid;
            site.ID    = new Guid("{7C039254-10B7-49F0-AA8D-F592206C7130}");
            context.SetWeb(web);
            var moleWeb = new Microsoft.SharePoint.Moles.MSPWeb(web);

            moleWeb.GetListString = (listUrl) =>
            {
                if (listUrl == "foo/bar/Lists/" + ConfigurationList.ConfigListName)
                {
                    return(list);
                }
                return(null);
            };
            //Act
            IPropertyBagHierarchy target = HierarchyBuilder.GetHierarchy(web);

            //Assert
            Assert.IsInstanceOfType(target, typeof(SandboxWithProxyPropertyBagHierarchy));
        }