Пример #1
0
        public void FieldDefinitions_ShouldHave_Correct_Indexed_Property()
        {
            var fieldDefinitionTypes = new List<Type>();

            fieldDefinitionTypes.AddRange(ReflectionUtils.GetTypesFromAssembly<FieldDefinition>(typeof(FieldDefinition).Assembly));
            fieldDefinitionTypes.AddRange(ReflectionUtils.GetTypesFromAssembly<FieldDefinition>(typeof(TaxonomyFieldDefinition).Assembly));

            foreach (var fieldDefintion in fieldDefinitionTypes)
            {
                Trace.WriteLine(string.Format("Checking Indexed prop for Indexed def:[{0}]", fieldDefintion.GetType().Name));

                var indexedSiteModel = SPMeta2Model.NewSiteModel(m => { });
                var indexedSiteField = ModelGeneratorService.GetRandomDefinition(fieldDefintion) as FieldDefinition;

                indexedSiteModel.AddField(indexedSiteField);
                indexedSiteField.Indexed = true;

                // dep lookiup
                if (indexedSiteField is DependentLookupFieldDefinition)
                {
                    var primaryLookupField = new LookupFieldDefinitionGenerator().GenerateRandomDefinition() as FieldDefinition;

                    (indexedSiteField as DependentLookupFieldDefinition).PrimaryLookupFieldId = primaryLookupField.Id;
                    indexedSiteModel.AddField(primaryLookupField);
                }

                TestModel(indexedSiteModel);

                Trace.WriteLine(string.Format("Checking Indexed prop for non-Indexed def:[{0}]", fieldDefintion.GetType().Name));

                var nonIdexedSiteModel = SPMeta2Model.NewSiteModel(m => { });
                var nonIndexedSiteField = ModelGeneratorService.GetRandomDefinition(fieldDefintion) as FieldDefinition;

                nonIdexedSiteModel.AddField(nonIndexedSiteField);
                nonIndexedSiteField.Indexed = false;

                // dep lookiup
                if (indexedSiteField is DependentLookupFieldDefinition)
                {
                    var primaryLookupField = new LookupFieldDefinitionGenerator().GenerateRandomDefinition() as FieldDefinition;

                    (nonIndexedSiteField as DependentLookupFieldDefinition).PrimaryLookupFieldId = primaryLookupField.Id;
                    nonIdexedSiteModel.AddField(primaryLookupField);
                }

                TestModel(nonIdexedSiteModel);
            }
        }
Пример #2
0
        public void FieldDefinitions_ShouldHave_Correct_ValidationMessageAndFormula_Property()
        {
            var fieldDefinitionTypes = new List<Type>();

            fieldDefinitionTypes.AddRange(ReflectionUtils.GetTypesFromAssembly<FieldDefinition>(typeof(FieldDefinition).Assembly));
            fieldDefinitionTypes.AddRange(ReflectionUtils.GetTypesFromAssembly<FieldDefinition>(typeof(TaxonomyFieldDefinition).Assembly));

            foreach (var fieldDefintion in fieldDefinitionTypes)
            {
                Trace.WriteLine(string.Format("Checking Indexed propr for Indexed def:[{0}]", fieldDefintion.GetType().Name));

                var siteModel = SPMeta2Model.NewSiteModel(m => { });
                var siteField = ModelGeneratorService.GetRandomDefinition(fieldDefintion) as FieldDefinition;

                siteModel.AddField(siteField);

                // dep lookiup
                if (siteField is DependentLookupFieldDefinition)
                {
                    var primaryLookupField = new LookupFieldDefinitionGenerator().GenerateRandomDefinition() as FieldDefinition;

                    (siteField as DependentLookupFieldDefinition).PrimaryLookupFieldId = primaryLookupField.Id;
                    siteModel.AddField(primaryLookupField);
                }

                siteField.ValidationMessage = string.Format("validatin_msg_{0}", RegressionService.RndService.String());
                siteField.ValidationFormula = string.Format("=[ID] * {0}", RegressionService.RndService.Int(100));

                TestModel(siteModel);
            }
        }