Exemplo n.º 1
0
        public void ChoiceFieldInfo_ShouldContainChoicesXmlInSchema()
        {
            // Arrange
            var id              = Guid.NewGuid();
            var internalName    = "InternalName";
            var displayName     = "DisplayNameResourceKey";
            var description     = "DescriptionNameResourceKey";
            var group           = "GroupResourceKey";
            var expectedChoices = new[]
            {
                "My choice 1",
                "My choice 2",
            };

            // Act
            var fieldInfo = new ChoiceFieldInfo(internalName, id, displayName, description, group)
            {
                DefaultValue = "My choice 1"
            };

            fieldInfo.Choices.AddRange(expectedChoices);

            var baseFieldXml = GetBaseFieldXml(internalName, id, displayName, description, group);
            var fieldSchema  = fieldInfo.Schema(baseFieldXml);
            var choicesNode  = fieldSchema.Descendants("CHOICES").Single();
            var choiceValues = choicesNode.Descendants("CHOICE").Select(node => node.Value);

            // Assert
            Assert.IsNotNull(choicesNode);
            Assert.AreEqual(2, choiceValues.Count());
        }
Exemplo n.º 2
0
        public void ChoiceFieldInfo_ShouldBeOfTypeChoice()
        {
            // Arrange
            var expectedFieldType = "Choice";

            // Act
            var fieldInfo = new ChoiceFieldInfo(
                "InternalName",
                Guid.NewGuid(),
                "DisplayNameResourceKey",
                "DescriptionNameResourceKey",
                "GroupResourceKey");
            var actualFieldType = fieldInfo.FieldType;

            // Assert
            Assert.AreEqual(expectedFieldType, actualFieldType);
        }