public void CanDeploy_SecurityRoleLink_ByName() { var securityGroup = ModelGeneratorService.GetRandomDefinition <SecurityGroupDefinition>(); var securityRole = ModelGeneratorService.GetRandomDefinition <SecurityRoleDefinition>(); var siteModel = SPMeta2Model .NewSiteModel(site => { site .AddSecurityGroup(securityGroup) .AddSecurityRole(securityRole); }); var webModel = SPMeta2Model .NewWebModel(web => { web.AddRandomWeb(rndWeb => { rndWeb.AddRandomList(rndList => { // rndList.AddRandomListItem(rndListItem => // { rndList.AddBreakRoleInheritance(new BreakRoleInheritanceDefinition(), secureListItem => { secureListItem.AddSecurityGroupLink(securityGroup, group => { group.AddSecurityRoleLink(new SecurityRoleLinkDefinition { SecurityRoleName = securityRole.Name }); }); }); // }); }); }); }); TestModels(new[] { siteModel, webModel }); }
public void CanDeploy_Default_PublishingPage() { var siteFeature = BuiltInSiteFeatures.SharePointServerPublishingInfrastructure.Inherit(f => f.Enable()); var webFeature = BuiltInWebFeatures.SharePointServerPublishing.Inherit(f => f.Enable()); var page = ModelGeneratorService.GetRandomDefinition <PublishingPageDefinition>(); var siteModel = SPMeta2Model.NewSiteModel(site => site.AddSiteFeature(siteFeature)); var webModel = SPMeta2Model.NewWebModel(web => { web.AddWebFeature(webFeature); web.AddHostList(BuiltInListDefinitions.Pages, list => { list.AddPublishingPage(page); }); }); TestModels(new ModelNode[] { siteModel, webModel }); }
public void CanDeploy_CoreProperty_As_URL() { WithExpectedUnsupportedCSOMnO365RunnerExceptions(() => { var propDef = ModelGeneratorService.GetRandomDefinition <CorePropertyDefinition>(def => { def.Type = BuiltInPropertyDataType.URL; def.Length = 1 + Rnd.Int(10); }); var model = SPMeta2Model.NewSiteModel(site => { site.AddCoreProperty(propDef); }); TestModel(model); }); }
public void CanDeploy_XsltListViewWebPart_WithXslLink() { var xslFileName = string.Format("m2.{0}.xsl", Rnd.String()); var xsltListViewWebpart = ModelGeneratorService.GetRandomDefinition <XsltListViewWebPartDefinition>(def => { def.ListId = Guid.Empty; def.ListTitle = BuiltInListDefinitions.SitePages.Title; def.ListUrl = string.Empty; def.ViewName = string.Empty; def.ViewId = null; // this needs to be set to get XslLink working // either SP1 issue or http context = null def.BaseXsltHashKey = Guid.NewGuid().ToString(); def.XslLink = "/Style Library/" + xslFileName; }); var model = SPMeta2Model .NewWebModel(web => { web .AddHostList(BuiltInListDefinitions.StyleLibrary, list => { list.AddModuleFile(new ModuleFileDefinition { Content = Encoding.UTF8.GetBytes(XsltStrings.XsltListViewWebPart_TestXsl), FileName = xslFileName }); }) .AddHostList(BuiltInListDefinitions.SitePages, list => { list .AddRandomWebPartPage(page => { page.AddXsltListViewWebPart(xsltListViewWebpart); }); }); }); TestModel(model); }
public void CanDeploy_LookupField_AsSingleSelectAndBindToListUrl_OnSubWeb() { var subWeb = ModelGeneratorService.GetRandomDefinition <WebDefinition>(def => { }); var lookupEnvironment = GetLookupFieldEnvironment(env => { env.LookupField.LookupListUrl = env.ChildList.GetListUrl(); env.LookupField.LookupWebUrl = UrlUtility.CombineUrl("~sitecollection", subWeb.Url); }, subWeb); TestModels(new ModelNode[] { lookupEnvironment.ChildListModel, lookupEnvironment.SiteModel, lookupEnvironment.MasterListModel }); }
public void CanDeploy_TaxonomyFieldBindedToTermById() { var termSet = new TaxonomyTermSetDefinition { Name = Rnd.String(), Description = Rnd.String(), }; var term = new TaxonomyTermDefinition { Name = Rnd.String(), Description = Rnd.String(), Id = Guid.NewGuid() }; var taxField = ModelGeneratorService.GetRandomDefinition <TaxonomyFieldDefinition>(def => { def.TermSetName = termSet.Name; def.TermId = term.Id.Value; }); var taxonomyModel = SPMeta2Model.NewSiteModel(site => { site.AddRandomTermStore(termStore => { termStore.AddRandomTermGroup(group => { group.AddTaxonomyTermSet(termSet, t => { t.AddTaxonomyTerm(term); }); }); }); }); var fieldModel = SPMeta2Model .NewSiteModel(site => { site.AddTaxonomyField(taxField); }); TestModels(new[] { taxonomyModel, fieldModel }); }
public void CanDeploy_TaxonomyFieldAsEmptyMiltiSelect() { var taxField = ModelGeneratorService.GetRandomDefinition <TaxonomyFieldDefinition>(def => { def.IsMulti = true; def.UseDefaultSiteCollectionTermStore = false; def.SspId = null; def.SspName = string.Empty; }); var model = SPMeta2Model .NewSiteModel(site => { site.AddTaxonomyField(taxField); }); TestModel(model); }
public void CanDeploy_XsltListViewWebPart_ByListId() { WithDisabledDefinitionImmutabilityValidation(() => { var sourceList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { }); var xsltListViewWebpart = ModelGeneratorService.GetRandomDefinition <XsltListViewWebPartDefinition>(def => { // list id will be updated later in OnProvisioned // we need to set something here // to pass property validation which requires one of the properties set def.ListId = Guid.NewGuid(); def.ListTitle = string.Empty; def.ListUrl = string.Empty; def.ViewName = string.Empty; def.ViewId = null; }); var model = SPMeta2Model .NewWebModel(web => { web .AddList(sourceList, list => { list.OnProvisioned <object>(context => { xsltListViewWebpart.ListId = ExtractListId(context); }); }) .AddHostList(BuiltInListDefinitions.SitePages, list => { list .AddRandomWebPartPage(page => { page.AddXsltListViewWebPart(xsltListViewWebpart); }); }); }); TestModel(model); }); }
public void CanDeploy_ListItem_ToList() { var list = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.EnableMinorVersions = false; def.TemplateType = BuiltInListTemplateTypeId.GenericList; }); var model = SPMeta2Model .NewWebModel(web => { web.AddList(list, rndList => { rndList.AddRandomListItem(); }); }); TestModel(model); }
public void CanDeploy_ModuleFile_MoreThan_511_Times_WithModeration() { if (!TestOptions.EnableModuleFile511Tests) { return; } var list = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.EnableVersioning = true; def.EnableMinorVersions = true; def.EnableModeration = true; def.TemplateType = BuiltInListTemplateTypeId.DocumentLibrary; }); CanDeploy_ModuleFile_MoreThan_511_Times(list); }
protected void AddWebWorkflow(ModelNode web) { var workflow = ModelGeneratorService.GetRandomDefinition <SP2013WorkflowDefinition>(); var historyList = GetHistoryList(); var taskList = GetTaskList(); web .AddSP2013Workflow(workflow) .AddList(historyList) .AddList(taskList) .AddSP2013WorkflowSubscription(new SP2013WorkflowSubscriptionDefinition { Name = Rnd.String(), WorkflowDisplayName = workflow.DisplayName, HistoryListUrl = historyList.GetListUrl(), TaskListUrl = taskList.GetListUrl() }); }
public void CanDeploy_ReusableItemsToFolder() { var reusableHtml = ModelGeneratorService.GetRandomDefinition <ReusableHTMLItemDefinition>(); var reusableText = ModelGeneratorService.GetRandomDefinition <ReusableTextItemDefinition>(); var model = SPMeta2Model.NewWebModel(web => { web.AddHostList(BuiltInListDefinitions.ReusableContent, list => { list.AddRandomFolder(folder => { folder.AddReusableHTMLItem(reusableHtml); folder.AddReusableTextItem(reusableText); }); }); }); TestModel(model); }
public void CanDeploy_TaxonomyTermGroupByNameAndId() { var termGroup = ModelGeneratorService.GetRandomDefinition <TaxonomyTermGroupDefinition>(def => { def.Id = Guid.NewGuid(); }); var model = SPMeta2Model .NewSiteModel(site => { site .AddRandomTermStore(store => { store.AddTaxonomyTermGroup(termGroup); }); }); TestModel(model); }
public void CanDeploy_MetadataNavigationSettings_With_Hierarchies_And_KeyFilters() { WithExcpectedException(typeof(SPMeta2NotImplementedException), () => { var managedNavSettings = ModelGeneratorService.GetRandomDefinition <MetadataNavigationSettingsDefinition>( def => { def.Hierarchies.Clear(); def.KeyFilters.Clear(); def.Hierarchies.Add(new MetadataNavigationHierarchy { FieldId = BuiltInFieldId.ContentTypeId }); def.KeyFilters.Add(new MetadataNavigationKeyFilter { FieldId = BuiltInFieldId.Created }); def.KeyFilters.Add(new MetadataNavigationKeyFilter { FieldId = BuiltInFieldId.Modified }); }); var model = SPMeta2Model.NewWebModel(web => { web.AddWebFeature(BuiltInWebFeatures.MetadataNavigationAndFiltering.Inherit(f => { f.Enable = true; })); web.AddRandomDocumentLibrary(list => { list.AddMetadataNavigationSettings(managedNavSettings); }); }); TestModel(model); }); }
public void CanDeploy_SecurityGroupLink_OnPublishingPage() { var securityGroup = ModelGeneratorService.GetRandomDefinition <SecurityGroupDefinition>(); var siteModel = SPMeta2Model .NewSiteModel(site => { site.AddSecurityGroup(securityGroup); site.AddSiteFeature(BuiltInSiteFeatures.SharePointServerPublishingInfrastructure.Inherit(f => { f.Enable = true; })); }); var webModel = SPMeta2Model .NewWebModel(web => { web.AddRandomWeb(rndWeb => { rndWeb.AddWebFeature(BuiltInWebFeatures.SharePointServerPublishing.Inherit(f => { f.Enable = true; })); rndWeb.AddHostList(BuiltInListDefinitions.Pages, sitePages => { sitePages.AddRandomPublishingPage(page => { page.OnProvisioning <object>(context => { TurnOffValidation(page); }); AddSecurityGroupLinkWithRoleLinks(page, securityGroup); }); }); }); }); TestModels(new ModelNode[] { siteModel, webModel }); }
public void CanDeploy_Default_WebPartPage_With_ContentType_ByName() { var webFeature = BuiltInWebFeatures.WikiPageHomePage.Inherit(f => f.Enable()); var contentTypeDef = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def => { def.ParentContentTypeId = BuiltInContentTypeId.WebPartPage; }); var itemDef = ModelGeneratorService.GetRandomDefinition <WebPartPageDefinition>(def => { def.ContentTypeName = contentTypeDef.Name; }); var siteModel = SPMeta2Model.NewSiteModel(site => { site.AddContentType(contentTypeDef); }); var listDef = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.ContentTypesEnabled = true; def.TemplateType = BuiltInListTemplateTypeId.DocumentLibrary; }); var webModel = SPMeta2Model.NewWebModel(web => { web.AddFeature(webFeature); //web.AddHostList(BuiltInListDefinitions.SitePages.Inherit(d => web.AddList(listDef.Inherit(d => { d.ContentTypesEnabled = true; }), list => { list.AddContentTypeLink(contentTypeDef); list.AddWebPartPage(itemDef); }); }); TestModel(siteModel, webModel); }
public void CanDeploy_Simple_Site_WithNullableSecondaryContactLogin() { WithExpectedUnsupportedCSOMnO365RunnerExceptions(() => { var site = ModelGeneratorService.GetRandomDefinition <SiteDefinition>(); //site.PrefixName = string.Empty; site.SecondaryContactEmail = null; site.SecondaryContactLogin = null; site.SecondaryContactName = null; var model = SPMeta2Model.NewWebApplicationModel(webApplication => { webApplication.AddSite(site); }); TestModel(model); }); }
public void CanDeploy_LookupField_With_CountRelated() { var field1 = ModelGeneratorService.GetRandomDefinition <LookupFieldDefinition>(def => { def.CountRelated = Rnd.Bool(); }); var field2 = ModelGeneratorService.GetRandomDefinition <LookupFieldDefinition>(def => { def.CountRelated = !field1.CountRelated; }); var siteModel = SPMeta2Model.NewSiteModel(site => { site.AddField(field1); site.AddField(field2); }); TestModel(siteModel); }
public void CanDeploy_WelcomePage_ToLibraryFolder() { var listDefinition = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.TemplateType = BuiltInListTemplateTypeId.DocumentLibrary; }); var model = SPMeta2Model.NewWebModel(web => { web.AddList(listDefinition, list => { list.AddRandomFolder(folder => { folder.AddRandomWelcomePage(); }); }); }); TestModel(model); }
public void CanDeploy_Field_WithRawXmlAndAdditionalAttributes() { WithDisabledPropertyUpdateValidation(() => { var internalName = Rnd.String(); var id = Guid.NewGuid(); var title = Rnd.String(); var group = Rnd.String(); var xmlElement = new XElement("Field", new XAttribute(BuiltInFieldAttributes.ID, id.ToString("B")), new XAttribute(BuiltInFieldAttributes.StaticName, internalName), new XAttribute(BuiltInFieldAttributes.DisplayName, title), new XAttribute(BuiltInFieldAttributes.Title, title), new XAttribute(BuiltInFieldAttributes.Name, internalName), new XAttribute(BuiltInFieldAttributes.Type, BuiltInFieldTypes.Text), new XAttribute(BuiltInFieldAttributes.Group, group)); var def = ModelGeneratorService.GetRandomDefinition <FieldDefinition>(); // ID/InternalName should be defined to be able to lookup the field def.Id = id; def.FieldType = BuiltInFieldTypes.Text; def.InternalName = internalName; def.Title = title; def.Group = group; def.RawXml = xmlElement.ToString(); def.AdditionalAttributes.Add(new FieldAttributeValue("Commas", Rnd.Bool().ToString().ToUpper())); def.AdditionalAttributes.Add(new FieldAttributeValue("AllowDuplicateValues", Rnd.Bool().ToString().ToUpper())); var siteModel = SPMeta2Model.NewSiteModel(site => { site.AddField(def); }); TestModel(siteModel); }); }
public void CanDeploy_ContentTypeLink_With_SiteAndWebContentTypes() { var siteContentType = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(); var webContentType = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(); var webList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.ContentTypesEnabled = true; }); var siteModel = SPMeta2Model.NewSiteModel(site => { site.AddContentType(siteContentType); }); var webModel = SPMeta2Model.NewWebModel(web => { web.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(f => { f.Enable = true; })); web.AddRandomWeb(subWeb => { subWeb.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(f => { f.Enable = true; })); subWeb.AddContentType(webContentType); subWeb.AddList(webList, list => { list.AddContentTypeLink(siteContentType); list.AddContentTypeLink(webContentType); }); }); }); TestModel(siteModel, webModel); }
public void CanDeploy_DocumentLibrary_With_WebCollectionToken_DocumentTemplateUrl() { var templateFileName = Rnd.TxtFileName(); var webModel = SPMeta2Model .NewWebModel(web => { var randomList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { //def.EnableVersioning = true; //def.EnableMinorVersions = true; //def.EnableModeration = true; def.TemplateType = BuiltInListTemplateTypeId.DocumentLibrary; }); // add first to provision, add a module web.AddList(randomList, list => { list.AddHostFolder(BuiltInFolderDefinitions.Forms, folder => { folder.AddModuleFile(new ModuleFileDefinition { FileName = templateFileName, Content = Encoding.UTF8.GetBytes(Rnd.String()) }); }); }); // add a clone second time with the template var listWithDocumentTemplate = randomList.Inherit(); #pragma warning disable 618 listWithDocumentTemplate.DocumentTemplateUrl = string.Format("~site/" + randomList.GetListUrl() + "/Forms/" + templateFileName); #pragma warning restore 618 web.AddList(listWithDocumentTemplate); }); TestModel(webModel); }
public void CanGetHashForAllDefinitions() { var service = new MD5HashCodeServiceBase(); var spMetaAssembly = typeof(FieldDefinition).Assembly; var spMetaStandardAssembly = typeof(TaxonomyFieldDefinition).Assembly; var allDefinitions = ReflectionUtils.GetTypesFromAssemblies <DefinitionBase>(new[] { spMetaAssembly, spMetaStandardAssembly }); var hashes = new Dictionary <string, string>(); Trace.WriteLine("Checking hashes for definitions..."); foreach (var defType in allDefinitions) { var defInstance = ModelGeneratorService.GetRandomDefinition(defType); Trace.WriteLine(string.Format("Definition:[{0}] - [{1}]", defType, defInstance)); TraceUtils.WithScope(trace => { var hash1 = service.GetHashCode(defInstance); var hash2 = service.GetHashCode(defInstance); trace.WriteLine(string.Format("HASH1:[{0}]", hash1)); trace.WriteLine(string.Format("HASH1:[{0}]", hash2)); // just curious, would it ever blow up on duplicate? hashes.Add(hash1, hash1); Assert.IsNotNull(hash1); Assert.IsNotNull(hash2); Assert.IsTrue(hash1 == hash2); }); } }
protected CalculatedFieldDefinition GetCalculatedFieldDefinition(Action <CalculatedFieldDefinition> action) { var result = ModelGeneratorService.GetRandomDefinition <CalculatedFieldDefinition>(def => { def.ShowInNewForm = true; def.ShowInEditForm = true; def.ShowInDisplayForm = true; def.ShowInListSettings = true; def.Hidden = false; def.Required = false; }); if (action != null) { action(result); } return(result); }
public void CanDeploy_SecurityRoleLink_Under_SecurityGroup() { // Incorrect provision order for SecurityGroup / SecurityRole #1017 // https://github.com/SubPointSolutions/spmeta2/issues/1017 var securityGroupDef = ModelGeneratorService.GetRandomDefinition <SecurityGroupDefinition>(); var securityRoleDef = ModelGeneratorService.GetRandomDefinition <SecurityRoleDefinition>(); var siteModel = SPMeta2Model.NewSiteModel(site => { site .AddSecurityRole(securityRoleDef) .AddSecurityGroup(securityGroupDef, securityGroup => { securityGroup.AddSecurityRoleLink(securityRoleDef.Name); }); }); TestModel(siteModel); }
public void CanDeploy_TaxonomyTermSetByName() { var termSet = ModelGeneratorService.GetRandomDefinition <TaxonomyTermSetDefinition>(def => { }); var model = SPMeta2Model .NewSiteModel(site => { site .AddRandomTermStore(store => { store.AddRandomTermGroup(group => { group.AddTaxonomyTermSet(termSet); }); }); }); TestModel(model); }
public void CanDeploy_LookupField_AsSingleSelectAndBindToListByTitle_OnSubWeb() { WithDisabledPropertyUpdateValidation(() => { var subWeb = ModelGeneratorService.GetRandomDefinition <WebDefinition>(def => { }); var lookupEnvironment = GetLookupFieldEnvironment(env => { env.LookupField.LookupListTitle = env.ChildList.Title; env.LookupField.LookupWebUrl = UrlUtility.CombineUrl("~sitecollection", subWeb.Url); }, subWeb); TestModels(new ModelNode[] { lookupEnvironment.ChildListModel, lookupEnvironment.SiteModel, lookupEnvironment.MasterListModel }); }); }
public void CanDeploy_ContentTypeFieldLink_OnSiteContentType() { var siteFieldOne = ModelGeneratorService.GetRandomDefinition <FieldDefinition>(); var siteFieldTwo = ModelGeneratorService.GetRandomDefinition <FieldDefinition>(); var siteContentType = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(); var siteModel = SPMeta2Model.NewSiteModel(site => { site.AddField(siteFieldOne); site.AddField(siteFieldTwo); site.AddContentType(siteContentType, c => { c.AddContentTypeFieldLink(siteFieldOne); c.AddContentTypeFieldLink(siteFieldTwo); }); }); TestModels(new[] { siteModel }); }
public void CanDeploy_ModuleFile_ToLibrary_FormsFolder() { var list = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.TemplateType = BuiltInListTemplateTypeId.DocumentLibrary; }); var model = SPMeta2Model .NewWebModel(web => { web.AddList(list, rndList => { rndList.AddHostFolder(BuiltInFolderDefinitions.Forms, folder => { folder.AddRandomModuleFile(); }); }); }); TestModel(model); }
public void CanDeploy_ListItemEventReceiver() { var eventReceiver = ModelGeneratorService.GetRandomDefinition <EventReceiverDefinition>(); eventReceiver.Assembly = "Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"; eventReceiver.Class = "Microsoft.SharePoint.Help.HelpLibraryEventReceiver"; eventReceiver.Synchronization = BuiltInEventReceiverSynchronization.Synchronous; eventReceiver.Type = BuiltInEventReceiverType.ItemAdded; var model = SPMeta2Model .NewWebModel(web => { web.AddRandomList(list => { list.AddEventReceiver(eventReceiver); }); }); TestModel(model); }
public static TextFieldDefinition GetRandomTextField(ModelGeneratorService service) { return service.GetRandomDefinition<TextFieldDefinition>(def => { def.ShowInDisplayForm = true; def.ShowInEditForm = true; def.ShowInListSettings = true; def.ShowInNewForm = true; def.ShowInVersionHistory = true; def.ShowInViewForms = true; def.ValidationFormula = null; def.ValidationMessage = null; def.Indexed = false; def.Hidden = false; def.DefaultValue = string.Empty; def.Required = true; }); }