示例#1
0
 /// <summary>
 /// Initializes a new <see cref="ResultTypeInfo"/> instance
 /// </summary>
 /// <param name="name">The name of the type</param>
 /// <param name="displayTemplate">Display template metadata</param>
 /// <param name="resultSource">Result source metadata</param>
 public ResultTypeInfo(string name, DisplayTemplateInfo displayTemplate, ResultSourceInfo resultSource)
 {
     this.Name = name;
     this.DisplayProperties = new List<ManagedPropertyInfo>();
     this.Rules = new List<ResultTypeRuleInfo>();
     this.DisplayTemplate = displayTemplate;
     this.ResultSource = resultSource;
 }
        public void DisplayTemplateInfo_ShouldGenerateTokenizedPath()
        {
            // Arrange
            var displayTemplateInfo = new DisplayTemplateInfo("TestName", DisplayTemplateCategory.ContentSearch);
            var expectedTokenizedPath = "~sitecollection/_catalogs/masterpage/Display Templates/Content Web Parts/TestName.js";

            // Act
            var actualTokenizedPath = displayTemplateInfo.ItemTemplateTokenizedPath;

            // Assert
            Assert.AreEqual(expectedTokenizedPath, actualTokenizedPath);
        }
        public void DisplayTemplateInfo_ShouldSupportStringSerializationAndDeserialization()
        {
            var serializer = this.GetSerializer();

            var objectToSerialize = new DisplayTemplateInfo("TestName", DisplayTemplateCategory.Search);

            string serializedRepresentation = serializer.Serialize(objectToSerialize);

            var deserializedObject = serializer.Deserialize<DisplayTemplateInfo>(serializedRepresentation);

            Assert.AreEqual(objectToSerialize.Name, deserializedObject.Name);
            Assert.AreEqual(objectToSerialize.Category, deserializedObject.Category);
        }