private ShimSPViewFieldCollection InitializeSPViewFieldCollectionShim() { var result = new ShimSPViewFieldCollection(); result.Bind(new[] { "test-field-1" }); return(result); }
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 = () => { } }; }