public void GetViewFile_OnValidCall_ConfirmResult()
        {
            // Arrange
            var list = new ShimSPList
            {
                ParentWebGet = () => new ShimSPWeb
                {
                    GetFileString = _ => new ShimSPFile().Instance
                }
            }.Instance;

            var view = new ShimSPView
            {
                UrlGet = () => DummyString
            }.Instance;

            // Act
            var result = ExtensionMethods.GetViewFile(list, view);

            // Assert
            result.ShouldNotBeNull();
        }
Exemplo n.º 2
0
        public void TestInitialize()
        {
            _shimsContext = ShimsContext.Create();
            _spWeb        = new ShimSPWeb
            {
                CurrentUserGet = () => new ShimSPUser
                {
                    LoginNameGet = () => "LoginName"
                },
                SiteGet = () => new ShimSPSite
                {
                    WebApplicationGet = () =>
                    {
                        var shim = new ShimSPWebApplication();
                        new ShimSPPersistedObject(shim)
                        {
                            IdGet = () => Guid.Empty
                        };
                        return(shim);
                    }
                }
            };
            _shimSPFieldCollection = new ShimSPFieldCollection
            {
                ItemGetGuid = guid => new ShimSPField
                {
                    GetFieldValueString = stringValue => "[today]",
                    TypeGet             = () => SPFieldType.DateTime
                },
                GetFieldByInternalNameString = stringValue => new ShimSPField
                {
                    TypeGet      = () => SPFieldType.Calculated,
                    SchemaXmlGet = () => "<Default></Default>"
                }
            };
            _spSite = new ShimSPSite
            {
                RootWebGet  = () => _spWeb,
                OpenWebGuid = guid => new ShimSPWeb
                {
                    IDGet    = () => guid,
                    ListsGet = () => new ShimSPListCollection
                    {
                        ItemGetGuid = guidValue => new ShimSPList
                        {
                            IDGet            = () => guid,
                            GetItemByIdInt32 = intValue => new ShimSPListItem
                            {
                                FieldsGet = () => _shimSPFieldCollection
                            },
                            FieldsGet = () => _shimSPFieldCollection
                        }
                    }
                }
            };
            ShimSPContext.CurrentGet = () => new ShimSPContext
            {
                SiteGet = () => _spSite,
                WebGet  = () => _spWeb
            };
            var shimSpView = new ShimSPView
            {
                ViewFieldsGet = () => new ShimSPViewFieldCollection()
                {
                    CountGet = () => 1
                }
            };

            _shimSpList = new ShimSPList
            {
                FieldsGet = () => _shimSPFieldCollection
            };
            _getpmapprovals = new getpmapprovals();
            _privateObject  = new PrivateObject(_getpmapprovals);
            _privateObject.SetFieldOrProperty("site", (SPSite)_spSite);
            _privateObject.SetFieldOrProperty("view", (SPView)shimSpView);
            _privateObject.SetFieldOrProperty("list", (SPList)_shimSpList);
            var dataSet = new DataSet();

            dataSet.Tables.Add(GetDataTable("TimesheetMeta"));
            _privateObject.SetFieldOrProperty("dsTimesheetMeta", dataSet);
            ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = codeToRun => codeToRun();
        }
Exemplo n.º 3
0
 private void SetupVariables()
 {
     validations       = 0;
     publicStatic      = BindingFlags.Static | BindingFlags.Public;
     nonPublicStatic   = BindingFlags.Static | BindingFlags.NonPublic;
     publicInstance    = BindingFlags.Instance | BindingFlags.Public;
     nonPublicInstance = BindingFlags.Instance | BindingFlags.NonPublic;
     guid    = Guid.Parse(SampleGuidString1);
     request = new Dictionary <string, string>()
     {
         ["period"]     = DummyString,
         ["action"]     = DummyString,
         ["duser"]      = DummyString,
         ["ts_uids"]    = DummyString,
         ["tsitemuids"] = DummyString
     };
     currentDate = DateTime.Now;
     spWeb       = new ShimSPWeb()
     {
         IDGet                = () => guid,
         SiteGet              = () => spSite,
         ListsGet             = () => spListCollection,
         GetFolderString      = _ => spFolder,
         GetFileString        = _ => spFile,
         FoldersGet           = () => spFolderCollection,
         CurrentUserGet       = () => spUser,
         ServerRelativeUrlGet = () => SampleUrl,
         AllUsersGet          = () => new ShimSPUserCollection(),
         SiteUsersGet         = () => new ShimSPUserCollection(),
         TitleGet             = () => DummyString
     };
     spSite = new ShimSPSite()
     {
         IDGet             = () => guid,
         WebApplicationGet = () => new ShimSPWebApplication(),
         RootWebGet        = () => spWeb,
         FeaturesGet       = () => new ShimSPFeatureCollection()
         {
             ItemGetGuid = _ => new ShimSPFeature()
         },
         ContentDatabaseGet = () => new ShimSPContentDatabase()
     };
     spListCollection = new ShimSPListCollection()
     {
         TryGetListString = _ => spList,
         ItemGetString    = _ => spList,
         ItemGetGuid      = _ => spList
     };
     spList = new ShimSPList()
     {
         IDGet             = () => guid,
         FieldsGet         = () => spFieldCollection,
         GetItemByIdInt32  = _ => spListItem,
         ItemsGet          = () => spListItemCollection,
         GetItemsSPQuery   = _ => spListItemCollection,
         RootFolderGet     = () => spFolder,
         ParentWebGet      = () => spWeb,
         DefaultViewGet    = () => spView,
         ViewsGet          = () => spViewCollection,
         ContentTypesGet   = () => spContentTypeCollection,
         TitleGet          = () => DummyString,
         EventReceiversGet = () => new ShimSPEventReceiverDefinitionCollection(),
         DefaultViewUrlGet = () => SampleUrl
     };
     spListItemCollection = new ShimSPListItemCollection()
     {
         CountGet     = () => DummyInt,
         ItemGetInt32 = _ => spListItem
     };
     spListItem = new ShimSPListItem()
     {
         IDGet             = () => DummyInt,
         TitleGet          = () => DummyString,
         ItemGetString     = _ => DummyString,
         ItemGetGuid       = _ => DummyString,
         ItemSetGuidObject = (_, __) => { },
         Update            = () => { },
         FileGet           = () => spFile,
         ParentListGet     = () => spList,
         NameGet           = () => DummyString
     };
     spFieldCollection = new ShimSPFieldCollection()
     {
         GetFieldByInternalNameString = _ => spField,
         ContainsFieldString          = _ => false,
         GetFieldString = _ => spField,
         ItemGetString  = _ => spField
     };
     spField = new ShimSPField()
     {
         IdGet            = () => guid,
         TitleGet         = () => DummyString,
         InternalNameGet  = () => DummyString,
         ReadOnlyFieldGet = () => false,
         HiddenGet        = () => false,
         ReorderableGet   = () => true,
         TypeAsStringGet  = () => DummyString
     };
     spUser = new ShimSPUser()
     {
         IDGet          = () => DummyInt,
         IsSiteAdminGet = () => true,
         UserTokenGet   = () => new ShimSPUserToken(),
         EmailGet       = () => DummyString
     };
     spFolderCollection = new ShimSPFolderCollection()
     {
         ItemGetString = _ => spFolder,
         AddString     = _ => spFolder
     };
     spFolder = new ShimSPFolder()
     {
         ExistsGet     = () => false,
         SubFoldersGet = () => spFolderCollection,
         FilesGet      = () => spFileCollection,
         UrlGet        = () => SampleUrl,
         UniqueIdGet   = () => guid,
         ParentWebGet  = () => spWeb
     };
     spFileCollection = new ShimSPFileCollection()
     {
         CountGet = () => DummyInt,
         AddStringByteArrayBoolean = (_1, _2, _3) => spFile,
         AddStringStream           = (_1, _2) => spFile,
         ItemGetString             = _ => spFile
     };
     spFile = new ShimSPFile()
     {
         Delete                 = () => { },
         OpenBinaryStream       = () => null,
         NameGet                = () => DummyString,
         GetListItemStringArray = _ => spListItem
     };
     spViewCollection = new ShimSPViewCollection()
     {
         ItemGetString = _ => spView
     };
     spView = new ShimSPView()
     {
         ViewFieldsGet        = () => spViewFieldCollection,
         ServerRelativeUrlGet = () => SampleUrl
     };
     spViewFieldCollection   = new ShimSPViewFieldCollection();
     spContentTypeCollection = new ShimSPContentTypeCollection()
     {
         ItemGetString = _ => spContentType
     };
     spContentType = new ShimSPContentType()
     {
         IdGet         = () => default(SPContentTypeId),
         FieldLinksGet = () => spFieldLinkCollection
     };
     spFieldLinkCollection = new ShimSPFieldLinkCollection()
     {
         ItemGetGuid = _ => new ShimSPFieldLink()
     };
     transaction = new ShimSqlTransaction()
     {
         Commit   = () => { },
         Rollback = () => { }
     };
     dataReader = new ShimSqlDataReader()
     {
         Read             = () => false,
         GetInt32Int32    = _ => One,
         GetDateTimeInt32 = _ => currentDate,
         GetStringInt32   = _ => DummyString,
         GetGuidInt32     = _ => guid,
         Close            = () => { }
     };
 }