public void Map_ShouldFilterOutComposerSystemProperties() { var validProperty = "MainBody"; var definitionType = new PageDefinitionType { DataType = "String" }; var source = new PageType { Name = "SomePage", GUID = Guid.NewGuid(), Definitions = { new PageDefinition { Name = validProperty, Type = definitionType }, new PageDefinition { Name = ComposerProperties.Page, Type = definitionType }, new PageDefinition { Name = ComposerProperties.ContainerPage, Type = definitionType }, new PageDefinition { Name = ComposerProperties.ContentFunction, Type = definitionType }, new PageDefinition { Name = ComposerProperties.NeverUsed, Type = definitionType }, new PageDefinition { Name = ComposerProperties.PersonalizationData, Type = definitionType } } }; var subject = CreateSubject(); var result = subject.Map(source); Assert.AreEqual(validProperty, result.PropertyDefinitions.Single().Name); }
public void MapType_WhenTypeNameHasMapping_ShouldReturnMappedTypeName() { var subject = CreateSubject(); var definitionType = new PageDefinitionType { DataType = "String", TypeName = "EPiServer.SpecializedProperties.PropertyImageUrl" }; var propertyType = subject.MapType(definitionType); Assert.AreEqual("EPiServer.Url", propertyType.TypeName); }
public void MapType_WhenTypeNameHasNoMappingAnOptionIsNotSet_ShouldSetUIHintToNull() { var subject = CreateSubject(new OptionsFake { ForceLegacyPropertyWrapper = false }); var definitionType = new PageDefinitionType { DataType = "String", TypeName = "MyCustom.PropertyImageUrl" }; var propertyType = subject.MapType(definitionType); Assert.IsNull(propertyType.UIHint); }
public void MapType_WhenDataTypeIsTimeSpanAndUseNullableValueTypesIsSet_ShouldReturnNullableTimeSpan() { var subject = CreateSubject(new OptionsFake { UseNullableValueTypes = true }); var definitionType = new PageDefinitionType { TypeName = "EPiServer.SpecializedProperties.PropertyTimeSpan" }; var propertyType = subject.MapType(definitionType); Assert.AreEqual(typeof(TimeSpan?), propertyType.Type); }
public void MapType_WhenDataTypeIsNumberAndUseNullableValueTypesIsSet_ShouldReturnNullableInteger() { var subject = CreateSubject(new OptionsFake { UseNullableValueTypes = true }); var definitionType = new PageDefinitionType { DataType = "Number" }; var propertyType = subject.MapType(definitionType); Assert.AreEqual(typeof(int?), propertyType.Type); }
public void MapType_WhenDataTypeIsBooleanAndUseNullableValueTypesIsSet_ShouldReturnBoolean() { var subject = CreateSubject(new OptionsFake { UseNullableValueTypes = true }); var definitionType = new PageDefinitionType { DataType = "Boolean" }; var propertyType = subject.MapType(definitionType); Assert.AreEqual(typeof(bool), propertyType.Type); }
public void MapType_WhenTypeNameIsEmpty_ShouldReturnMappedDataType() { var subject = CreateSubject(); var definitionType = new PageDefinitionType { DataType = "String" }; var propertyType = subject.MapType(definitionType); Assert.AreEqual(typeof(string), propertyType.Type); }
public void MapType_WhenTypeNameHasNoMapping_ShouldReturnTypeAsBackingType() { var subject = CreateSubject(); var definitionType = new PageDefinitionType { DataType = "String", TypeName = "MyCustom.PropertyImageUrl" }; var propertyType = subject.MapType(definitionType); Assert.AreEqual(definitionType.TypeName, propertyType.BackingTypeName); }