Exemplo n.º 1
0
        protected virtual void SetupTestEntity()
        {
            var shimUser = new ShimUser();

            shimUser.UserIDGet = () => { return(UserId); };
            var user = shimUser.Instance;

            var shimEcnSession = new ShimECNSession();
            var ecnSession     = shimEcnSession.Instance;

            ecnSession.CurrentUser = user;

            var shimMasterPage = new ShimAccounts();

            shimMasterPage.UserSessionGet = () => { return(ecnSession); };
            var masterPage = shimMasterPage.Instance;

            var shimPage = new ShimPage();

            shimPage.MasterGet = () => { return(masterPage); };
            var page = shimPage.Instance;

            _testEntity        = new T();
            _testEntity.ID     = TestEntityId;
            _testEntity.Page   = page;
            _testEntityPrivate = new PrivateObject(_testEntity);
        }
Exemplo n.º 2
0
        public void ClientModelTest()
        {
            using (var scope = new SharePointEmulationScope(EmulationMode.Enabled))
            {
                // Create shims for the ClientContext class and its base class
                var ctx     = new ShimClientContext();
                var ctxBase = new ShimClientRuntimeContext(ctx);

                var site = new ShimSite();
                var web  = new ShimWeb();

                ctx.SiteGet      = () => { return(site); };
                ctx.WebGet       = () => { return(web); };
                ctx.ExecuteQuery = () => { };

                ImplementLoadFake <Web>(ctxBase);
                ImplementLoadFake <Site>(ctxBase);
                ImplementLoadFake <User>(ctxBase);

                var user          = new ShimUser();
                var userPrincipal = new ShimPrincipal(user);
                userPrincipal.LoginNameGet = () => { return("i:0#.f|membership|[email protected]"); };
                web.CurrentUserGet         = () => { return(user); };
                web.TitleGet = () => { return("Title"); };

                // Test with the ClientContext ctx
                var rCtx = ctx.Instance;
                rCtx.Load(rCtx.Web, w => w.Title);
                rCtx.Load(rCtx.Web.CurrentUser, u => u.LoginName);
                rCtx.ExecuteQuery();

                Assert.That(user.Instance.LoginName, Is.EqualTo("i:0#.f|membership|[email protected]"));
            }
        }