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 static bool[,] Smooth(this bool[,] array, int iterationCount = 1, int minNeighborCountToAdd = 4, int maxNeighborCountToRemove = 4, float probabilityToAdd = 1f, float probabilityToRemove = 1f) { bool[,] smoothed = (bool[, ])array.Clone(); for (int x = 0; x < smoothed.GetLength(0); x++) { for (int y = 0; y < smoothed.GetLength(1); y++) { int neighbourWallTiles = array.GetSurroundingWallCount(x, y); if (neighbourWallTiles > minNeighborCountToAdd && Rnd.Bool(probabilityToAdd)) { smoothed[x, y] = true; } else if (neighbourWallTiles < maxNeighborCountToRemove && Rnd.Bool(probabilityToRemove)) { smoothed[x, y] = false; } } } return(smoothed); }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { def.Name = Rnd.String(); def.Description = Rnd.String(); def.OnlyAllowMembersViewMembership = Rnd.Bool(); def.Owner = Rnd.UserLogin(); def.DefaultUser = Rnd.UserLogin(); def.AllowMembersEditMembership = Rnd.NullableBool(); def.AllowRequestToJoinLeave = Rnd.NullableBool(); def.AutoAcceptRequestToJoinLeave = Rnd.NullableBool(); if (!def.AllowRequestToJoinLeave.HasValue || !def.AllowRequestToJoinLeave.Value) { def.AutoAcceptRequestToJoinLeave = null; } })); }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { def.FieldId = BuiltInFieldId.CellPhone; if (Rnd.Bool()) { def.DisplayName = Rnd.String(); } if (Rnd.Bool()) { def.Hidden = Rnd.Bool(); } if (Rnd.Bool()) { def.Required = Rnd.Bool(); } })); }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { if (Rnd.Bool()) { def.AuditFlags = new Collection <string> { BuiltInAuditMaskType.CheckIn, BuiltInAuditMaskType.Copy, BuiltInAuditMaskType.Move }; } else { def.AuditFlags = new Collection <string> { BuiltInAuditMaskType.CheckIn, BuiltInAuditMaskType.Move }; } })); }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { def.Id = Rnd.String(); def.Title = Rnd.String(); def.ZoneId = "FullPage"; def.ZoneIndex = Rnd.Int(100); def.AndQueryTextBoxLabelText = Rnd.String(); def.DisplayGroup = Rnd.String(); def.LanguagesLabelText = Rnd.String(); def.NotQueryTextBoxLabelText = Rnd.String(); def.OrQueryTextBoxLabelText = Rnd.String(); def.PhraseQueryTextBoxLabelText = Rnd.String(); // TODO //def.AdvancedSearchBoxProperties = Rnd.String(); def.PropertiesSectionLabelText = Rnd.String(); def.ResultTypeLabelText = Rnd.String(); def.ScopeLabelText = Rnd.String(); def.ScopeSectionLabelText = Rnd.String(); def.SearchResultPageURL = Rnd.String(); def.ShowAndQueryTextBox = Rnd.Bool(); def.ShowLanguageOptions = Rnd.Bool(); def.ShowNotQueryTextBox = Rnd.Bool(); def.ShowOrQueryTextBox = Rnd.Bool(); def.ShowPhraseQueryTextBox = Rnd.Bool(); def.ShowPropertiesSection = Rnd.Bool(); def.ShowResultTypePicker = Rnd.Bool(); def.ShowScopes = Rnd.Bool(); def.TextQuerySectionLabelText = Rnd.String(); })); }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { if (Rnd.Bool()) { def.QuickLaunchEnabled = null; } else { def.QuickLaunchEnabled = Rnd.Bool(); } if (Rnd.Bool()) { def.TreeViewEnabled = null; } else { def.TreeViewEnabled = Rnd.Bool(); } })); }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { def.AllowPrint = Rnd.Bool(); def.AllowScript = Rnd.Bool(); def.AllowWriteCopy = Rnd.Bool(); def.DisableDocumentBrowserView = Rnd.Bool(); def.DocumentAccessExpireDays = Rnd.Int(300); def.DocumentLibraryProtectionExpireDate = Rnd.Date(); def.EnableDocumentAccessExpire = Rnd.Bool(); def.EnableDocumentBrowserPublishingView = Rnd.Bool(); def.EnableGroupProtection = Rnd.Bool(); def.EnableLicenseCacheExpire = Rnd.Bool(); def.GroupName = Rnd.UserEmail(); def.LicenseCacheExpireDays = Rnd.Int(255); def.PolicyDescription = Rnd.String(); def.PolicyTitle = Rnd.String(); })); }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { // ID must be more than 32 due ScriptEditorWebPart issue // it calculated hidden field name as 'this.ID.Substring(this.ID.Length - 36);' def.Id = Rnd.String(64); def.Title = Rnd.String(); def.ZoneId = "FullPage"; def.ZoneIndex = Rnd.Int(100); //def.WebpartXmlTemplate = DefaultWebpartTemplates.ContentEditorWebpart; def.WebpartFileName = BuiltInWebpartFileNames.MSContentEditor; if (Rnd.Bool()) { def.ExportMode = BuiltInExportMode.All; } def.Width = Rnd.Int(500); def.Height = Rnd.Int(500); })); }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { def.Title = Rnd.String(); def.FileName = Rnd.String() + ".html"; def.Description = Rnd.String(); var pageIndex = Rnd.Int(2); var pages = new[] { Encoding.UTF8.GetBytes(DefaultHtmlMasterPageTemplates.DesignManagerStarter) }; def.Content = pages[0]; def.NeedOverride = true; if (Rnd.Bool()) { def.DefaultCSSFile = string.Format("{0}.css", Rnd.String()); } })); }
public void CanDeploy_Field_WithAdditionalAttributes() { var def = ModelGeneratorService.GetRandomDefinition <FieldDefinition>(); 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); }
protected override void PostProcessDefinitionTemplate(FieldDefinition def) { base.PostProcessDefinitionTemplate(def); (def as BooleanFieldDefinition).DefaultValue = Rnd.Bool() ? "0" : "1"; }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { def.Title = Rnd.String(); def.Description = Rnd.String(); #pragma warning disable 618 def.Url = Rnd.String(16); #pragma warning restore 618 def.TemplateType = BuiltInListTemplateTypeId.GenericList; def.ContentTypesEnabled = Rnd.Bool(); var draftOpt = Rnd.Int(10); if (draftOpt > 1) { if (draftOpt <= 3) { def.DraftVersionVisibility = BuiltInDraftVisibilityTypes.Approver; def.EnableVersioning = true; //def.EnableMinorVersions = true; def.EnableModeration = true; } if (draftOpt >= 3 && draftOpt <= 6) { def.DraftVersionVisibility = BuiltInDraftVisibilityTypes.Author; def.EnableVersioning = true; //def.EnableMinorVersions = true; def.EnableModeration = true; } if (draftOpt > 6) { def.DraftVersionVisibility = BuiltInDraftVisibilityTypes.Reader; } } else { def.DraftVersionVisibility = string.Empty; } //def.NoCrawl = Rnd.NullableBool(); //def.OnQuickLaunch = Rnd.NullableBool(); //def.Hidden = Rnd.NullableBool(); //def.EnableAttachments = Rnd.NullableBool(); //def.EnableFolderCreation = Rnd.NullableBool(); //def.EnableMinorVersions = Rnd.NullableBool(); //def.EnableModeration = Rnd.NullableBool(); //def.EnableVersioning = Rnd.NullableBool(); //def.ForceCheckout = Rnd.NullableBool(); //def.EnableAssignToEmail = Rnd.NullableBool(); //def.DisableGridEditing = Rnd.NullableBool(); //if (def.ForceCheckout.HasValue && def.ForceCheckout.Value) //{ // def.TemplateType = BuiltInListTemplateTypeId.DocumentLibrary; //} //if (def.Hidden.HasValue && def.Hidden.Value) //{ // def.OnQuickLaunch = false; //} if (action != null) { action(def); } })); }
public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action) { return(WithEmptyDefinition(def => { // webs def.InheritWebTemplates = Rnd.Bool(); if (!def.InheritWebTemplates.Value) { def.UseAnyWebTemplate = Rnd.Bool(); } if (def.UseAnyWebTemplate.HasValue && !def.UseAnyWebTemplate.Value) { def.UseDefinedWebTemplates = true;// Rnd.Bool(); def.DefinedWebTemplates.Add(BuiltInWebTemplates.Collaboration.TeamSite); def.DefinedWebTemplates.Add(BuiltInWebTemplates.Collaboration.Blog); def.DefinedWebTemplates.Add(BuiltInWebTemplates.Collaboration.BlankSite); } def.ResetAllSubsitesToInheritWebTemplates = Rnd.Bool(); // page layouts def.InheritPageLayouts = Rnd.Bool(); if (!def.InheritPageLayouts.Value) { def.UseAnyPageLayout = Rnd.Bool(); } if (def.UseAnyPageLayout.HasValue && !def.UseAnyPageLayout.Value) { def.UseDefinedPageLayouts = true; Rnd.Bool(); def.DefinedPageLayouts.Add(BuiltInPublishingPageLayoutNames.ArticleLeft); def.DefinedPageLayouts.Add(BuiltInPublishingPageLayoutNames.ArticleRight); def.DefinedPageLayouts.Add(BuiltInPublishingPageLayoutNames.BlankWebPartPage); } def.ResetAllSubsitesToInheritPageLayouts = Rnd.Bool(); // default page layout def.InheritDefaultPageLayout = Rnd.Bool(); if (!def.InheritDefaultPageLayout.Value) { def.UseDefinedDefaultPageLayout = true; } Rnd.Bool(); if (def.UseDefinedDefaultPageLayout.HasValue && def.UseDefinedDefaultPageLayout.Value) { def.DefinedDefaultPageLayout = BuiltInPublishingPageLayoutNames.ArticleRight; } def.ResetAllSubsitesToInheritPageLayouts = Rnd.Bool(); // convert settings def.ConverBlankSpacesIntoHyphen = Rnd.Bool(); })); }
public void CanDeploy_WorkflowAssociation_UnderContentType_ReadOnly() { // .AddWorkflowAssociation() for Read Only Content Types throws error #1001 // https://github.com/SubPointSolutions/spmeta2/issues/1001 var taskList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.Hidden = true; def.TemplateType = BuiltInListTemplateTypeId.Tasks; }); var historyList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.Hidden = true; def.TemplateType = BuiltInListTemplateTypeId.WorkflowHistory; }); var workflowDef = ModelGeneratorService.GetRandomDefinition <WorkflowAssociationDefinition>(def => { def.TaskListTitle = taskList.Title; def.HistoryListTitle = historyList.Title; }); var initialSiteModel = SPMeta2Model.NewSiteModel(site => { AddDefaultWorkflowFeatures(site); }); var readOnlyContentTypeDef = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def => { def.ReadOnly = true; }); // changability // deploy the same association with different props var workflowDefChanges = workflowDef.Inherit(def => { var value = Rnd.Bool(); def.AllowManual = value; def.AutoStartChange = !value; def.AutoStartCreate = value; def.AssociationData = Rnd.String(); }); // lists are to be deployed before contet type // workflow association on the cotnent type references lists var webModel = SPMeta2Model.NewWebModel(web => { web.AddList(historyList); web.AddList(taskList); }); var siteModel = SPMeta2Model.NewSiteModel(site => { site.AddContentType(readOnlyContentTypeDef, contentType => { contentType.RegExcludeFromValidation(); contentType.AddWorkflowAssociation(workflowDef); contentType.AddWorkflowAssociation(workflowDefChanges); }); }); TestModels(new ModelNode[] { initialSiteModel, webModel, siteModel }); }
public void CanDeploy_WorkflowAssociation_UnderContentTypeLink_ReadOnly() { var contentTypeDef = ModelGeneratorService.GetRandomDefinition <ContentTypeDefinition>(def => { def.ReadOnly = true; }); var taskList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.Hidden = true; def.TemplateType = BuiltInListTemplateTypeId.Tasks; def.ContentTypesEnabled = true; }); var historyList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def => { def.Hidden = true; def.TemplateType = BuiltInListTemplateTypeId.WorkflowHistory; }); var workflowDef = ModelGeneratorService.GetRandomDefinition <WorkflowAssociationDefinition>(def => { def.TaskListTitle = taskList.Title; def.HistoryListTitle = historyList.Title; }); // changability // deploy the same association with different props var workflowDefChanges = workflowDef.Inherit(def => { var value = Rnd.Bool(); def.AllowManual = value; def.AutoStartChange = !value; def.AutoStartCreate = value; def.AssociationData = Rnd.String(); }); var siteModel = SPMeta2Model.NewSiteModel(site => { site.AddContentType(contentTypeDef, contentType => { contentType.RegExcludeFromValidation(); }); AddDefaultWorkflowFeatures(site); }); var model = SPMeta2Model.NewWebModel(web => { web.AddList(taskList); web.AddList(historyList); web.AddRandomList(list => { list.AddContentTypeLink(contentTypeDef, contentTypeLink => { contentTypeLink.AddWorkflowAssociation(workflowDef); contentTypeLink.AddWorkflowAssociation(workflowDefChanges); }); }); }); TestModel(siteModel, model); }