Esempio n. 1
0
        public void TestIsParserForValidDataTypeWithInvalidPrevalue()
        {
            // arrange
            var dataTypeServiceMock = new Mock <IDataTypeService>();

            var dataTypeDefinition =
                new DataTypeDefinition(global::Umbraco.Core.Constants.PropertyEditors.MultiNodeTreePickerAlias)
            {
                Id = 1
            };

            var prevalue = new JObject(new JProperty("type", "media"));

            dataTypeServiceMock.Setup(x => x.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id))
            .Returns(
                new PreValueCollection(
                    new Dictionary <string, PreValue> {
                { "startNode", new PreValue(prevalue.ToString()) }
            }));

            var parser = new MultiNodeTreePickerContentParser(dataTypeServiceMock.Object);

            // act
            var result = parser.IsParserFor(dataTypeDefinition);

            // verify
            dataTypeServiceMock.Verify(x => x.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id), Times.Once);

            Assert.IsFalse(result);
        }
Esempio n. 2
0
        public void TestIsParserForInValidDataType()
        {
            // arrange
            var dataTypeDefinition = new DataTypeDefinition("foo");

            var parser = new MultiNodeTreePickerContentParser();

            // act
            var result = parser.IsParserFor(dataTypeDefinition);

            // verify
            Assert.IsFalse(result);
        }