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", "content")); dataTypeServiceMock.Setup(x => x.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id)) .Returns( new PreValueCollection( new Dictionary <string, PreValue> { { "startNode", new PreValue(prevalue.ToString()) } })); var parser = new MultiNodeTreePickerMediaParser(dataTypeServiceMock.Object); // act var result = parser.IsParserFor(dataTypeDefinition); // verify dataTypeServiceMock.Verify(x => x.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id), Times.Once); Assert.IsFalse(result); }
public void TestIsParserForInValidDataType() { // arrange var dataTypeDefinition = new DataTypeDefinition("foo"); var parser = new MultiNodeTreePickerMediaParser(); // act var result = parser.IsParserFor(dataTypeDefinition); // verify Assert.IsFalse(result); }
public void TestGetLinkedEntitiesWithEmptyValue() { // arrange var parser = new MultiNodeTreePickerMediaParser(); // act var result = parser.GetLinkedEntities(null); // verify Assert.IsNotNull(result); var entities = result.ToList(); Assert.AreEqual(0, entities.Count()); }
public void TestGetLinkedEntitiesWithValue() { // arrange var parser = new MultiNodeTreePickerMediaParser(); // act var result = parser.GetLinkedEntities("100,101,104"); // verify Assert.IsNotNull(result); var entities = result.ToList(); Assert.AreEqual(3, entities.Count()); Assert.IsTrue(entities.Exists(x => x.LinkedEntityType == LinkedEntityType.Media && x.Id == 100)); Assert.IsTrue(entities.Exists(x => x.LinkedEntityType == LinkedEntityType.Media && x.Id == 101)); Assert.IsTrue(entities.Exists(x => x.LinkedEntityType == LinkedEntityType.Media && x.Id == 104)); }