protected LookupFieldEnvironment GetLookupFieldEnvironment(Action<LookupFieldEnvironment> action)
        {
            var result = new LookupFieldEnvironment();

            var dataList = ModelGeneratorService.GetRandomDefinition<ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;
            });

            var masterList = ModelGeneratorService.GetRandomDefinition<ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;
            });

            var lookupField = GetSingleSelectLookupDefinition(def =>
            {
                def.Indexed = false;
                //def.LookupListTitle = dataList.Title;
            });

            ModelNode childListNode = null;

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddField(lookupField);
            });

            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddField(lookupField);
            });

            var childWebModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(dataList, list =>
                {
                    childListNode = list;

                    list
                        .AddRandomListItem()
                        .AddRandomListItem()
                        .AddRandomListItem();
                });
            });

            var masterWebModel = SPMeta2Model.NewWebModel(web =>
            {
                web
                    .AddList(masterList, list =>
                    {
                        list.AddListFieldLink(lookupField);
                    });
            });

            result.LookupField = lookupField;

            result.ChildList = dataList;
            result.ChildListNode = childListNode;
            result.ChildListModel = childWebModel;


            result.MasterList = masterList;
            result.MasterListModel = masterWebModel;

            result.SiteModel = siteModel;
            result.WebModel = webModel;

            if (action != null)
                action(result);

            return result;
        }
Example #2
0
        protected LookupFieldEnvironment GetLookupFieldEnvironment(Action <LookupFieldEnvironment> action)
        {
            var result = new LookupFieldEnvironment();

            var dataList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;
            });

            var masterList = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType = BuiltInListTemplateTypeId.GenericList;
            });

            var lookupField = GetSingleSelectLookupDefinition(def =>
            {
                def.Indexed = false;
                //def.LookupListTitle = dataList.Title;
            });

            ModelNode childListNode = null;

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddField(lookupField);
            });

            var childWebModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(dataList, list =>
                {
                    childListNode = list;

                    list
                    .AddRandomListItem()
                    .AddRandomListItem()
                    .AddRandomListItem();
                });
            });

            var masterWebModel = SPMeta2Model.NewWebModel(web =>
            {
                web
                .AddList(masterList, list =>
                {
                    list.AddListFieldLink(lookupField);
                });
            });

            result.LookupField = lookupField;

            result.ChildList      = dataList;
            result.ChildListNode  = childListNode;
            result.ChildListModel = childWebModel;


            result.MasterList      = masterList;
            result.MasterListModel = masterWebModel;

            result.SiteModel = siteModel;

            if (action != null)
            {
                action(result);
            }

            return(result);
        }