public override ModelNode ReverseSingleHost(object reverseHost, ReverseOptions options)
        {
            var item    = (reverseHost as WebPartPageReverseHost).HostWebPartPageFile;
            var context = (reverseHost as WebPartPageReverseHost).HostClientContext;

            var def = new WebPartPageDefinition();

            def.FileName = item.Name;
            def.Title    = item.Title;

            // always reverse to CustomPageLayout
            // we don't know what is the content of the web part page
            using (var stream = File.OpenBinaryDirect(
                       context,
                       item.ServerRelativeUrl).Stream)
            {
                def.CustomPageLayout = Encoding.UTF8.GetString(ModuleFileUtils.ReadFully(stream));
            }

            def.NeedOverride = true;

            return(new WebPartPageModelNode
            {
                Options = { RequireSelfProcessing = true },
                Value = def
            });
        }
        public override ModelNode ReverseSingleHost(object reverseHost, ReverseOptions options)
        {
            var item    = (reverseHost as SandboxSolutionReverseHost).HostSandboxSolutionFile;
            var context = (reverseHost as SandboxSolutionReverseHost).HostClientContext;

            var def = new SandboxSolutionDefinition();

            def.FileName   = item.Name;
            def.SolutionId = ConvertUtils.ToGuid(item.ListItemAllFields["SolutionId"]).Value;

            def.Activate = true;

            using (var stream = File.OpenBinaryDirect(
                       context,
                       item.ServerRelativeUrl).Stream)
            {
                def.Content = ModuleFileUtils.ReadFully(stream);
            }

            return(new SandboxSolutionModelNode
            {
                Options = { RequireSelfProcessing = true },
                Value = def
            });
        }
Ejemplo n.º 3
0
        public static byte[] GetContent(this SPFile file)
        {
            byte[] result = null;

            using (var stream = file.OpenBinaryStream())
                result = ModuleFileUtils.ReadFully(stream);

            return(result);
        }
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());

            var folder     = folderModelHost.CurrentLibraryFolder;
            var definition = model.WithAssertAndCast <PublishingPageLayoutDefinition>("model", value => value.RequireNotNull());

            var spObject = FindPublishingPage(folderModelHost.CurrentList, folder, definition);
            var spFile   = spObject.File;

            var context = spObject.Context;

            context.Load(spObject);
            context.Load(spObject, o => o.DisplayName);

            context.Load(spFile, f => f.ServerRelativeUrl);

            context.ExecuteQuery();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.FileName, o => o.GetFileName())
                         .ShouldBeEqual(m => m.Description, o => o.GetPublishingPageLayoutDescription())
                         .ShouldBeEndOf(m => m.AssociatedContentTypeId, o => o.GetPublishingPageLayoutAssociatedContentTypeId())
                         .ShouldBeEqual(m => m.Title, o => o.GetTitle());

            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.Content);
                //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                var isContentValid = false;

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spFile.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                var srcStringContent = s.Content;
                var dstStringContent = Encoding.UTF8.GetString(dstContent);

                srcStringContent = srcStringContent
                                   .Replace("meta:webpartpageexpansion=\"full\" ", string.Empty);

                isContentValid = dstStringContent.Contains(srcStringContent);

                return(new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    // Dst = dstProp,
                    IsValid = isContentValid
                });
            });
        }
Ejemplo n.º 5
0
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());

            var folder     = folderModelHost.CurrentLibraryFolder;
            var definition = model.WithAssertAndCast <TemplateDefinitionBase>("model", value => value.RequireNotNull());

            var spFile   = GetItemFile(folderModelHost.CurrentList, folder, definition.FileName);
            var spObject = spFile.ListItemAllFields;

            var context = spObject.Context;

            context.Load(spObject);
            context.Load(spFile, f => f.ServerRelativeUrl);
            context.ExecuteQuery();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.Title, o => o.GetTitle())
                         .ShouldBeEqual(m => m.FileName, o => o.GetFileName())

                         //.ShouldBeEqual(m => m.CrawlerXSLFile, o => o.GetCrawlerXSLFile())
                         .ShouldBeEqual(m => m.HiddenTemplate, o => o.GetHiddenTemplate())
                         .ShouldBeEqual(m => m.Description, o => o.GetMasterPageDescription())
            ;

            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.Content);
                //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                var isContentValid = false;

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spFile.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                var srcStringContent = Encoding.UTF8.GetString(s.Content);
                var dstStringContent = Encoding.UTF8.GetString(dstContent);

                isContentValid = dstStringContent.Contains(srcStringContent);

                return(new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    // Dst = dstProp,
                    IsValid = isContentValid
                });
            });
        }
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());
            var definition = model.WithAssertAndCast <ModuleFileDefinition>("model", value => value.RequireNotNull());

            var folder   = folderHost.CurrentLibraryFolder;
            var spObject = GetFile(folderHost, definition);

            if (!spObject.IsObjectPropertyInstantiated("Name"))
            {
                spObject.Context.Load(spObject, o => o.Name);
            }

            if (!spObject.IsObjectPropertyInstantiated("ServerRelativeUrl"))
            {
                spObject.Context.Load(spObject, o => o.ServerRelativeUrl);
            }

            spObject.Context.ExecuteQuery();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.FileName, o => o.Name);

            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.Content);
                //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                var isContentValid = false;

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderHost.HostClientContext, spObject.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                isContentValid = dstContent.SequenceEqual(definition.Content);

                return(new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    // Dst = dstProp,
                    IsValid = isContentValid
                });
            });
        }
        public override ModelNode ReverseSingleHost(object reverseHost, ReverseOptions options)
        {
            var item    = (reverseHost as ModuleFileReverseHost).HostFile;
            var context = (reverseHost as ModuleFileReverseHost).HostClientContext;

            var def = new ModuleFileDefinition();

            def.FileName = item.Name;

            using (var stream = File.OpenBinaryDirect(
                       context,
                       item.ServerRelativeUrl).Stream)
            {
                def.Content = ModuleFileUtils.ReadFully(stream);
            }

            return(new ModuleFileModelNode
            {
                Options = { RequireSelfProcessing = true },
                Value = def
            });
        }
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());

            var folder     = folderModelHost.CurrentListFolder;
            var definition = model.WithAssertAndCast <WebPartGalleryFileDefinition>("model", value => value.RequireNotNull());

            var file     = GetItemFile(folderModelHost.CurrentList, folder, definition.FileName);
            var spObject = file.ListItemAllFields;

            var context = spObject.Context;

            context.Load(file, f => f.ServerRelativeUrl);
            context.Load(spObject);
            context.ExecuteQueryWithTrace();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.Title, o => o.GetTitle())
                         .ShouldBeEqual(m => m.FileName, o => o.GetName())

                         .ShouldBeEqual(m => m.Description, o => o.GetWebPartGalleryFileDescription())
                         .ShouldBeEqual(m => m.Group, o => o.GetWebPartGalleryFileGroup())
            ;

            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.Content);
                //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                var isContentValid = true;

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, file.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                var srcStringContent = Encoding.UTF8.GetString(s.Content);
                var dstStringContent = Encoding.UTF8.GetString(dstContent);

                srcStringContent = WebpartXmlExtensions
                                   .LoadWebpartXmlDocument(srcStringContent)
                                   .SetTitle(s.Title)
                                   .SetOrUpdateProperty("Description", s.Description)
                                   .ToString();


                dstStringContent = WebpartXmlExtensions.LoadWebpartXmlDocument(dstStringContent).ToString();


                isContentValid = dstStringContent.Contains(srcStringContent);

                return(new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    // Dst = dstProp,
                    IsValid = isContentValid
                });
            });

            if (definition.RecommendationSettings.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(m => m.RecommendationSettings);
                    var isValid = true;

                    // TODO
                    //var targetControlTypeValue = d.GetWebPartGalleryFileRecommendationSettings();
                    //var targetControlTypeValues = new List<string>();

                    //for (var i = 0; i < targetControlTypeValue.Count; i++)
                    //    targetControlTypeValues.Add(targetControlTypeValue[i].ToUpper());

                    //foreach (var v in s.RecommendationSettings)
                    //{
                    //    if (!targetControlTypeValues.Contains(v.ToUpper()))
                    //        isValid = false;
                    //}

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.RecommendationSettings, "RecommendationSettings is empty. Skipping.");
            }
        }
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());
            var definition      = model.WithAssertAndCast <WebPartPageDefinition>("model", value => value.RequireNotNull());

            var folder  = folderModelHost.CurrentListFolder;
            var context = folder.Context;

            var pageName = GetSafeWebPartPageFileName(definition);
            var pageFile = GetCurrentWebPartPageFile(folderModelHost.CurrentList, folder, pageName);

            var spObject = pageFile.ListItemAllFields;

            context.Load(spObject);
            context.Load(spObject, s => s.File);

            context.ExecuteQueryWithTrace();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.FileName, o => o.GetName());

            assert.SkipProperty(m => m.Title, "Web part pages don't have title. Skipping.");

            if (!string.IsNullOrEmpty(definition.CustomPageLayout))
            {
                var custmPageContent    = Encoding.UTF8.GetBytes(definition.CustomPageLayout);
                var pageTemplateContent = definition.GetWebPartPageTemplateContent();

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spObject.File.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(m => m.PageLayoutTemplate);

                    var isValidPageLayoutTemplate = custmPageContent.SequenceEqual(dstContent);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        //Dst = dstProp,
                        IsValid = isValidPageLayoutTemplate
                    });
                });

                assert.SkipProperty(m => m.PageLayoutTemplate, "PageLayoutTemplate validated with GetWebPartPageTemplateContent() call before.");
                assert.SkipProperty(m => m.CustomPageLayout, "CustomPageLayout validated with GetCustomnPageContent() call before.");
            }
            else
            {
                assert.SkipProperty(m => m.CustomPageLayout, "CustomPageLayout is null or empty. Skipping.");
            }

            if (definition.PageLayoutTemplate > 0)
            {
                var pageTemplateContent = definition.GetWebPartPageTemplateContent();

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spObject.File.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(m => m.PageLayoutTemplate);

                    var isValidPageLayoutTemplate = pageTemplateContent.SequenceEqual(dstContent);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        //Dst = dstProp,
                        IsValid = isValidPageLayoutTemplate
                    });
                });

                assert.SkipProperty(m => m.PageLayoutTemplate, "PageLayoutTemplate validated with GetWebPartPageTemplateContent() call before.");
            }
            else
            {
                assert.SkipProperty(m => m.CustomPageLayout, "PageLayoutTemplate is o or less. Skipping.");
            }
        }
Ejemplo n.º 10
0
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());
            var definition = model.WithAssertAndCast <ModuleFileDefinition>("model", value => value.RequireNotNull());

            var stringCustomContentType = string.Empty;

            if (!string.IsNullOrEmpty(definition.ContentTypeName) ||
                !string.IsNullOrEmpty(definition.ContentTypeId))
            {
                stringCustomContentType = ResolveContentTypeId(folderHost, definition);
            }

            var folder   = folderHost.CurrentListFolder;
            var spObject = GetFile(folderHost, definition);

            if (folderHost.CurrentList != null)
            {
                if (!spObject.IsObjectPropertyInstantiated("ListItemAllFields"))
                {
                    spObject.Context.Load(spObject, o => o.ListItemAllFields);
                }
            }

            if (!spObject.IsObjectPropertyInstantiated("Name"))
            {
                spObject.Context.Load(spObject, o => o.Name);
            }

            if (!spObject.IsObjectPropertyInstantiated("ServerRelativeUrl"))
            {
                spObject.Context.Load(spObject, o => o.ServerRelativeUrl);
            }


            spObject.Context.ExecuteQueryWithTrace();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.FileName, o => o.Name);

            if (!string.IsNullOrEmpty(definition.ContentTypeId))
            {
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeId, "ContentTypeId is null or empty. Skipping.");
            }

            if (!string.IsNullOrEmpty(definition.ContentTypeName))
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(def => def.ContentTypeName);
                    var currentContentTypeName = d.ListItemAllFields["ContentTypeId"].ToString();

                    var isValis = stringCustomContentType == currentContentTypeName;

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValis
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeName, "ContentTypeName is null or empty. Skipping.");
            }

            if (definition.DefaultValues.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = true;

                    foreach (var srcValue in s.DefaultValues)
                    {
                        // big TODO here for == !=

                        if (!string.IsNullOrEmpty(srcValue.FieldName))
                        {
                            if (d.ListItemAllFields[srcValue.FieldName].ToString() != srcValue.Value.ToString())
                            {
                                isValid = false;
                            }
                        }

                        if (!isValid)
                        {
                            break;
                        }
                    }

                    var srcProp = s.GetExpressionValue(def => def.DefaultValues);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.DefaultValues, "DefaultValues.Count == 0. Skipping.");
            }

            // skip all templates
            if (definition.FileName.ToUpper().EndsWith("DOTX"))
            {
                assert.SkipProperty(m => m.Content, "DOTX file is detected. Skipping.");
            }
            else
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(m => m.Content);
                    //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                    var isContentValid = false;

                    byte[] dstContent = null;

                    using (var stream = File.OpenBinaryDirect(folderHost.HostClientContext, spObject.ServerRelativeUrl).Stream)
                        dstContent = ModuleFileUtils.ReadFully(stream);

                    isContentValid = dstContent.SequenceEqual(definition.Content);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        // Dst = dstProp,
                        IsValid = isContentValid
                    });
                });
            }
        }
Ejemplo n.º 11
0
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost",
                                                                                value => value.RequireNotNull());

            var folder     = folderModelHost.CurrentListFolder;
            var definition = model.WithAssertAndCast <MasterPagePreviewDefinition>("model", value => value.RequireNotNull());

            var spFile   = GetItemFile(folderModelHost.CurrentList, folder, definition.FileName);
            var spObject = spFile.ListItemAllFields;

            var context = spObject.Context;

            context.Load(spObject);
            context.Load(spFile, f => f.ServerRelativeUrl);
            context.ExecuteQueryWithTrace();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.Title, o => o.GetTitle())
                         .ShouldBeEqual(m => m.FileName, o => o.GetFileName());

            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.Content);
                //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                var isContentValid = false;

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spFile.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                isContentValid = dstContent.SequenceEqual(definition.Content);

                return(new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    // Dst = dstProp,
                    IsValid = isContentValid
                });
            });

            if (definition.UIVersion.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp      = s.GetExpressionValue(def => def.UIVersion);
                    var dstPropValue = d.GetUIVersion();

                    var isValid = true;

                    foreach (var v in s.UIVersion)
                    {
                        if (!dstPropValue.Contains(v))
                        {
                            isValid = false;
                            break;
                        }
                    }

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(d => d.UIVersion, "UIVersion.Count is 0. Skipping");
            }

            #endregion
        }
Ejemplo n.º 12
0
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());

            var folder     = folderModelHost.CurrentLibraryFolder;
            var definition = model.WithAssertAndCast <ItemControlTemplateDefinitionBase>("model", value => value.RequireNotNull());

            var spFile   = GetItemFile(folderModelHost.CurrentList, folder, definition.FileName);
            var spObject = spFile.ListItemAllFields;

            var context = spObject.Context;

            context.Load(spObject);
            context.Load(spFile, f => f.ServerRelativeUrl);
            context.ExecuteQuery();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.Title, o => o.GetTitle())
                         .ShouldBeEqual(m => m.FileName, o => o.GetFileName())

                         //.ShouldBeEqual(m => m.CrawlerXSLFile, o => o.GetCrawlerXSLFile())
                         .ShouldBeEqual(m => m.HiddenTemplate, o => o.GetHiddenTemplate())
                         .ShouldBeEqual(m => m.Description, o => o.GetMasterPageDescription())
            ;

            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.Content);
                //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                var isContentValid = false;

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spFile.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                var srcStringContent = Encoding.UTF8.GetString(s.Content);
                var dstStringContent = Encoding.UTF8.GetString(dstContent);

                isContentValid = dstStringContent.Contains(srcStringContent);

                return(new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    // Dst = dstProp,
                    IsValid = isContentValid
                });
            });

            #region preview field

            if (!string.IsNullOrEmpty(definition.PreviewURL))
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = false;
                    var srcProp = s.GetExpressionValue(m => m.PreviewURL);

                    var previewValue = d.GetPreviewURL();
                    isValid          = (previewValue != null) &&
                                       (d.GetPreviewURL().Url == s.PreviewURL);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.PreviewURL, "PreviewURL is NULL. Skipping");
            }

            if (!string.IsNullOrEmpty(definition.PreviewDescription))
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = false;
                    var srcProp = s.GetExpressionValue(m => m.PreviewDescription);

                    var previewValue = d.GetPreviewURL();
                    isValid          = (previewValue != null) &&
                                       (d.GetPreviewURL().Description == s.PreviewDescription);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.PreviewDescription, "PreviewDescription is NULL. Skipping");
            }

            #endregion

            #region TargetControlTypes

            if (definition.TargetControlTypes.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(m => m.TargetControlTypes);
                    var isValid = true;

                    //var targetControlTypeValue = new FieldMultiChoiceValue(d["TargetControlType"].ToString());
                    //var targetControlTypeValues = new List<string>();

                    //for (var i = 0; i < targetControlTypeValue.Count; i++)
                    //    targetControlTypeValues.Add(targetControlTypeValue[i].ToUpper());

                    //foreach (var v in s.TargetControlTypes)
                    //{
                    //    if (!targetControlTypeValues.Contains(v.ToUpper()))
                    //        isValid = false;
                    //}

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.TargetControlTypes, "TargetControlTypes count is 0. Skipping");
            }

            #endregion
        }
Ejemplo n.º 13
0
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());

            var folder     = folderModelHost.CurrentListFolder;
            var definition = model.WithAssertAndCast <HtmlMasterPageDefinition>("model", value => value.RequireNotNull());

            var spObject = FindPage(folderModelHost.CurrentList, folder, definition);
            var spFile   = FindPageFile(folderModelHost.CurrentList, folder, definition);

            var context = spObject.Context;

            context.Load(spObject);
            context.Load(spObject, o => o.DisplayName);

            context.Load(spFile);
            context.Load(spFile, o => o.ServerRelativeUrl);

            context.ExecuteQueryWithTrace();

            var stringCustomContentType = string.Empty;

            if (!string.IsNullOrEmpty(definition.ContentTypeName) ||
                !string.IsNullOrEmpty(definition.ContentTypeId))
            {
                if (!string.IsNullOrEmpty(definition.ContentTypeName))
                {
                    stringCustomContentType = ContentTypeLookupService
                                              .LookupContentTypeByName(folderModelHost.CurrentList, definition.ContentTypeName)
                                              .Name;
                }
            }


            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.FileName, o => o.GetFileName())
                         .ShouldBeEqual(m => m.DefaultCSSFile, o => o.GetDefaultCSSFile())
                         .ShouldBeEqual(m => m.Description, o => o.GetMasterPageDescription())
                         .ShouldBeEqual(m => m.Title, o => o.GetTitle());

            // check that there is a .master page with the same name in the library
            var associatedMasterPageName = definition.FileName.ToLower().EndsWith(".html")
                ? definition.FileName.ToLower().Replace(".html", ".master")
                : definition.FileName + ".master";

            var associatedMasterPage = FindPageByName(folderModelHost.CurrentList, folder, associatedMasterPageName);

            assert.ShouldNotBeNull(associatedMasterPage);

            if (definition.UIVersion.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp      = s.GetExpressionValue(def => def.UIVersion);
                    var dstPropValue = d.GetUIVersion();

                    var isValid = true;

                    foreach (var v in s.UIVersion)
                    {
                        if (!dstPropValue.Contains(v))
                        {
                            isValid = false;
                            break;
                        }
                    }

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(d => d.UIVersion, "UIVersion.Count is 0. Skipping");
            }


            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.Content);
                //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                var isContentValid = false;

                byte[] dstContent = null;

                folderModelHost.HostClientContext.ExecuteQueryWithTrace();

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spFile.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                var srcStringContent = Encoding.UTF8.GetString(s.Content);
                var dstStringContent = Encoding.UTF8.GetString(dstContent);

                // same or greater, length
                // too tricky to compare the content
                //isContentValid = dstStringContent.Contains(srcStringContent);
                isContentValid = dstStringContent.Length >= srcStringContent.Length;

                return(new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    // Dst = dstProp,
                    IsValid = isContentValid
                });
            });


            if (!string.IsNullOrEmpty(definition.ContentTypeName))
            {
                assert.ShouldBeEqual(m => m.ContentTypeName, o => o.GetContentTypeName());
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeName, "ContentTypeName is NULL. Skipping.");
            }

            if (!string.IsNullOrEmpty(definition.ContentTypeId))
            {
                // TODO
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeId, "ContentTypeId is null or empty. Skipping.");
            }

            if (!string.IsNullOrEmpty(definition.ContentTypeName))
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(def => def.ContentTypeName);
                    var currentContentTypeName = d.ContentType.Name;

                    var isValis = stringCustomContentType == currentContentTypeName;

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValis
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeName, "ContentTypeName is null or empty. Skipping.");
            }

            if (definition.DefaultValues.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = true;

                    foreach (var srcValue in s.DefaultValues)
                    {
                        // big TODO here for == !=

                        if (!string.IsNullOrEmpty(srcValue.FieldName))
                        {
                            if (d[srcValue.FieldName].ToString() != srcValue.Value.ToString())
                            {
                                isValid = false;
                            }
                        }

                        if (!isValid)
                        {
                            break;
                        }
                    }

                    var srcProp = s.GetExpressionValue(def => def.DefaultValues);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.DefaultValues, "DefaultValues.Count == 0. Skipping.");
            }

            if (definition.Values.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = true;

                    foreach (var srcValue in s.Values)
                    {
                        // big TODO here for == !=

                        if (!string.IsNullOrEmpty(srcValue.FieldName))
                        {
                            if (d[srcValue.FieldName].ToString() != srcValue.Value.ToString())
                            {
                                isValid = false;
                            }
                        }

                        if (!isValid)
                        {
                            break;
                        }
                    }

                    var srcProp = s.GetExpressionValue(def => def.Values);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.Values, "Values.Count == 0. Skipping.");
            }
        }
Ejemplo n.º 14
0
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());

            var folder     = folderModelHost.CurrentListFolder;
            var definition = model.WithAssertAndCast <TemplateDefinitionBase>("model", value => value.RequireNotNull());

            var spFile   = GetItemFile(folderModelHost.CurrentList, folder, definition.FileName);
            var spObject = spFile.ListItemAllFields;

            var context = spObject.Context;

            context.Load(spObject);
            context.Load(spFile, f => f.ServerRelativeUrl);
            context.ExecuteQueryWithTrace();

            var stringCustomContentType = string.Empty;

            if (!string.IsNullOrEmpty(definition.ContentTypeName) ||
                !string.IsNullOrEmpty(definition.ContentTypeId))
            {
                if (!string.IsNullOrEmpty(definition.ContentTypeName))
                {
                    stringCustomContentType = ContentTypeLookupService
                                              .LookupContentTypeByName(folderModelHost.CurrentList, definition.ContentTypeName)
                                              .Name;
                }
            }


            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.Title, o => o.GetTitle())
                         .ShouldBeEqual(m => m.FileName, o => o.GetFileName())

                         //.ShouldBeEqual(m => m.CrawlerXSLFile, o => o.GetCrawlerXSLFile())
                         .ShouldBeEqual(m => m.HiddenTemplate, o => o.GetHiddenTemplate())
                         //.ShouldBeEqual(m => m.Description, o => o.GetMasterPageDescription())
            ;

            if (!string.IsNullOrEmpty(definition.Description))
            {
                assert.ShouldBeEqual(m => m.Description, o => o.GetMasterPageDescription());
            }
            else
            {
                assert.SkipProperty(m => m.Description, "Description is null. Skiping.");
            }

            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.Content);
                //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                var isContentValid = false;

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spFile.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                var srcStringContent = Encoding.UTF8.GetString(s.Content);
                var dstStringContent = Encoding.UTF8.GetString(dstContent);

                isContentValid = dstStringContent.Contains(srcStringContent);

                return(new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    // Dst = dstProp,
                    IsValid = isContentValid
                });
            });



            if (!string.IsNullOrEmpty(definition.ContentTypeName))
            {
                assert.ShouldBeEqual(m => m.ContentTypeName, o => o.GetContentTypeName());
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeName, "ContentTypeName is NULL. Skipping.");
            }

            if (!string.IsNullOrEmpty(definition.ContentTypeId))
            {
                // TODO
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeId, "ContentTypeId is null or empty. Skipping.");
            }

            if (!string.IsNullOrEmpty(definition.ContentTypeName))
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(def => def.ContentTypeName);
                    var currentContentTypeName = d.ContentType.Name;

                    var isValis = stringCustomContentType == currentContentTypeName;

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValis
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeName, "ContentTypeName is null or empty. Skipping.");
            }

            if (definition.DefaultValues.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = true;

                    foreach (var srcValue in s.DefaultValues)
                    {
                        // big TODO here for == !=

                        if (!string.IsNullOrEmpty(srcValue.FieldName))
                        {
                            if (d[srcValue.FieldName].ToString() != srcValue.Value.ToString())
                            {
                                isValid = false;
                            }
                        }

                        if (!isValid)
                        {
                            break;
                        }
                    }

                    var srcProp = s.GetExpressionValue(def => def.DefaultValues);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.DefaultValues, "DefaultValues.Count == 0. Skipping.");
            }

            if (definition.Values.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = true;

                    foreach (var srcValue in s.Values)
                    {
                        // big TODO here for == !=

                        if (!string.IsNullOrEmpty(srcValue.FieldName))
                        {
                            if (d[srcValue.FieldName].ToString() != srcValue.Value.ToString())
                            {
                                isValid = false;
                            }
                        }

                        if (!isValid)
                        {
                            break;
                        }
                    }

                    var srcProp = s.GetExpressionValue(def => def.Values);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.Values, "Values.Count == 0. Skipping.");
            }
        }
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());

            var folder     = folderModelHost.CurrentListFolder;
            var definition = model.WithAssertAndCast <PublishingPageLayoutDefinition>("model", value => value.RequireNotNull());

            var stringCustomContentType = string.Empty;

            if (!string.IsNullOrEmpty(definition.ContentTypeName) ||
                !string.IsNullOrEmpty(definition.ContentTypeId))
            {
                if (!string.IsNullOrEmpty(definition.ContentTypeName))
                {
                    stringCustomContentType = ContentTypeLookupService
                                              .LookupContentTypeByName(folderModelHost.CurrentList, definition.ContentTypeName)
                                              .Name;
                }
            }

            var spObject = FindPublishingPage(folderModelHost.CurrentList, folder, definition);
            var spFile   = spObject.File;

            var context = spObject.Context;

            context.Load(spObject);
            context.Load(spObject, o => o.DisplayName);
            context.Load(spObject, o => o.ContentType);

            context.Load(spFile, f => f.ServerRelativeUrl);

            context.ExecuteQueryWithTrace();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.FileName, o => o.GetFileName());


            if (!string.IsNullOrEmpty(definition.Title))
            {
                assert.ShouldBeEqual(m => m.Title, o => o.GetTitle());
            }
            else
            {
                assert.SkipProperty(m => m.Title);
            }

            if (!string.IsNullOrEmpty(definition.Description))
            {
                assert.ShouldBeEqual(m => m.Description, o => o.GetPublishingPageLayoutDescription());
            }
            else
            {
                assert.SkipProperty(m => m.Description);
            }

            if (!string.IsNullOrEmpty(definition.AssociatedContentTypeId))
            {
                assert.ShouldBeEndOf(m => m.AssociatedContentTypeId, o => o.GetPublishingPageLayoutAssociatedContentTypeId());
            }
            else
            {
                assert.SkipProperty(m => m.AssociatedContentTypeId, "AssociatedContentTypeId is null or empty.");
            }

            if (!string.IsNullOrEmpty(definition.PreviewImageUrl))
            {
                var urlValue = spObject.FieldValues["PublishingPreviewImage"] as FieldUrlValue;

                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(m => m.PreviewImageUrl);
                    var isValid = (urlValue != null) && (urlValue.Url == s.PreviewImageUrl);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });

                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(m => m.PreviewImageDescription);
                    var isValid = (urlValue != null) && (urlValue.Description == s.PreviewImageDescription);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.PreviewImageUrl, "MasterPageUrl is NULL");
                assert.SkipProperty(m => m.PreviewImageDescription, "MasterPageDescription is NULL");
            }

            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.Content);
                //var dstProp = d.GetExpressionValue(ct => ct.GetId());

                var isContentValid = false;

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spFile.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                var srcStringContent = s.Content;
                var dstStringContent = Encoding.UTF8.GetString(dstContent);

                srcStringContent = srcStringContent
                                   .Replace("meta:webpartpageexpansion=\"full\" ", string.Empty);

                isContentValid = dstStringContent.Contains(srcStringContent);

                return(new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    // Dst = dstProp,
                    IsValid = isContentValid
                });
            });


            if (!string.IsNullOrEmpty(definition.ContentTypeId))
            {
                // TODO
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeId, "ContentTypeId is null or empty. Skipping.");
            }

            if (!string.IsNullOrEmpty(definition.ContentTypeName))
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(def => def.ContentTypeName);
                    var currentContentTypeName = d.ContentType.Name;

                    var isValis = stringCustomContentType == currentContentTypeName;

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValis
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeName, "ContentTypeName is null or empty. Skipping.");
            }

            if (definition.DefaultValues.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = true;

                    foreach (var srcValue in s.DefaultValues)
                    {
                        // big TODO here for == !=

                        if (!string.IsNullOrEmpty(srcValue.FieldName))
                        {
                            if (d[srcValue.FieldName].ToString() != srcValue.Value.ToString())
                            {
                                isValid = false;
                            }
                        }

                        if (!isValid)
                        {
                            break;
                        }
                    }

                    var srcProp = s.GetExpressionValue(def => def.DefaultValues);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.DefaultValues, "DefaultValues.Count == 0. Skipping.");
            }

            if (definition.Values.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = true;

                    foreach (var srcValue in s.Values)
                    {
                        // big TODO here for == !=

                        if (!string.IsNullOrEmpty(srcValue.FieldName))
                        {
                            if (d[srcValue.FieldName].ToString() != srcValue.Value.ToString())
                            {
                                isValid = false;
                            }
                        }

                        if (!isValid)
                        {
                            break;
                        }
                    }

                    var srcProp = s.GetExpressionValue(def => def.Values);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.Values, "Values.Count == 0. Skipping.");
            }
        }
Ejemplo n.º 16
0
        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var folderModelHost = modelHost.WithAssertAndCast <FolderModelHost>("modelHost", value => value.RequireNotNull());
            var definition      = model.WithAssertAndCast <WebPartPageDefinition>("model", value => value.RequireNotNull());

            var folder  = folderModelHost.CurrentListFolder;
            var context = folder.Context;

            var pageName = GetSafeWebPartPageFileName(definition);
            var pageFile = GetCurrentWebPartPageFile(folderModelHost.CurrentList, folder, pageName);

            var stringCustomContentType = string.Empty;

            if (!string.IsNullOrEmpty(definition.ContentTypeName) ||
                !string.IsNullOrEmpty(definition.ContentTypeId))
            {
                if (!string.IsNullOrEmpty(definition.ContentTypeName))
                {
                    stringCustomContentType = ContentTypeLookupService
                                              .LookupContentTypeByName(folderModelHost.CurrentList, definition.ContentTypeName)
                                              .Name;
                }
            }

            var spObject = pageFile.ListItemAllFields;

            context.Load(spObject);
            context.Load(spObject, s => s.ContentType);
            context.Load(spObject, s => s.File);

            context.ExecuteQueryWithTrace();

            var assert = ServiceFactory.AssertService
                         .NewAssert(definition, spObject)
                         .ShouldNotBeNull(spObject)
                         .ShouldBeEqual(m => m.FileName, o => o.GetFileLeafRef());

            assert.SkipProperty(m => m.Title, "Web part pages don't have title. Skipping.");

            if (!string.IsNullOrEmpty(definition.CustomPageLayout))
            {
                var custmPageContent    = Encoding.UTF8.GetBytes(definition.CustomPageLayout);
                var pageTemplateContent = definition.GetWebPartPageTemplateContent();

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spObject.File.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(m => m.PageLayoutTemplate);

                    var isValidPageLayoutTemplate = custmPageContent.SequenceEqual(dstContent);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        //Dst = dstProp,
                        IsValid = isValidPageLayoutTemplate
                    });
                });

                assert.SkipProperty(m => m.PageLayoutTemplate, "PageLayoutTemplate validated with GetWebPartPageTemplateContent() call before.");
                assert.SkipProperty(m => m.CustomPageLayout, "CustomPageLayout validated with GetCustomnPageContent() call before.");
            }
            else
            {
                assert.SkipProperty(m => m.CustomPageLayout, "CustomPageLayout is null or empty. Skipping.");
            }

            if (definition.PageLayoutTemplate > 0)
            {
                var pageTemplateContent = definition.GetWebPartPageTemplateContent();

                byte[] dstContent = null;

                using (var stream = File.OpenBinaryDirect(folderModelHost.HostClientContext, spObject.File.ServerRelativeUrl).Stream)
                    dstContent = ModuleFileUtils.ReadFully(stream);

                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(m => m.PageLayoutTemplate);

                    var isValidPageLayoutTemplate = pageTemplateContent.SequenceEqual(dstContent);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        //Dst = dstProp,
                        IsValid = isValidPageLayoutTemplate
                    });
                });

                assert.SkipProperty(m => m.PageLayoutTemplate, "PageLayoutTemplate validated with GetWebPartPageTemplateContent() call before.");
            }
            else
            {
                assert.SkipProperty(m => m.CustomPageLayout, "PageLayoutTemplate is o or less. Skipping.");
            }

            if (!string.IsNullOrEmpty(definition.ContentTypeId))
            {
                // TODO
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeId, "ContentTypeId is null or empty. Skipping.");
            }

            if (!string.IsNullOrEmpty(definition.ContentTypeName))
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var srcProp = s.GetExpressionValue(def => def.ContentTypeName);
                    var currentContentTypeName = d.ContentType.Name;

                    var isValis = stringCustomContentType == currentContentTypeName;

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValis
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.ContentTypeName, "ContentTypeName is null or empty. Skipping.");
            }

            if (definition.DefaultValues.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = true;

                    foreach (var srcValue in s.DefaultValues)
                    {
                        // big TODO here for == !=

                        if (!string.IsNullOrEmpty(srcValue.FieldName))
                        {
                            if (d[srcValue.FieldName].ToString() != srcValue.Value.ToString())
                            {
                                isValid = false;
                            }
                        }

                        if (!isValid)
                        {
                            break;
                        }
                    }

                    var srcProp = s.GetExpressionValue(def => def.DefaultValues);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.DefaultValues, "DefaultValues.Count == 0. Skipping.");
            }


            if (definition.Values.Count > 0)
            {
                assert.ShouldBeEqual((p, s, d) =>
                {
                    var isValid = true;

                    foreach (var srcValue in s.Values)
                    {
                        // big TODO here for == !=

                        if (!string.IsNullOrEmpty(srcValue.FieldName))
                        {
                            if (d[srcValue.FieldName].ToString() != srcValue.Value.ToString())
                            {
                                isValid = false;
                            }
                        }

                        if (!isValid)
                        {
                            break;
                        }
                    }

                    var srcProp = s.GetExpressionValue(def => def.Values);

                    return(new PropertyValidationResult
                    {
                        Tag = p.Tag,
                        Src = srcProp,
                        Dst = null,
                        IsValid = isValid
                    });
                });
            }
            else
            {
                assert.SkipProperty(m => m.Values, "Values.Count == 0. Skipping.");
            }
        }