Пример #1
0
        public void ShouldReturnEqualtyByNames()
        {
            PropertyEditorAttribute attribute1 = new PropertyEditorAttribute("type");
            PropertyEditorAttribute attribute2 = new PropertyEditorAttribute("type");

            Assert.IsTrue(attribute1.Equals(attribute2));
            Assert.IsTrue(attribute2.Equals(attribute1));
        }
Пример #2
0
        public void ShouldReturnPropertyEditorByAttributes()
        {
            PropertyEditorAttribute attribute = new PropertyEditorAttribute(typeof(PropertyEditorMock));
            Editor editor = EditorCollection.GetPropertyEditorByAttributes(new AttributeCollection(new Attribute[] { attribute }));

            Assert.IsNotNull(editor);
            Assert.IsInstanceOfType(editor, typeof(PropertyEditorMock));
        }
Пример #3
0
        public void ShouldReturnTypeNameBasedHashCode()
        {
            int hash1 = new PropertyEditorAttribute("type").GetHashCode();
            int hash2 = new PropertyEditorAttribute("type").GetHashCode();
            int hash3 = new PropertyEditorAttribute("newtype").GetHashCode();

            Assert.AreEqual <int>(hash1, hash2);
            Assert.AreNotEqual <int>(hash1, hash3);
        }
Пример #4
0
        public IPropertyGirdCell Create(PropertyEditorAttribute attribute)
        {
            Type attributeType = attribute.GetType();

            Debug.Assert(_cells.Keys.Contains(attributeType), "没有为PropertyEditorAttribute映射相应的EditingControl");
            if (_cells.Keys.Contains(attributeType))
            {
                return(Activator.CreateInstance(_cells[attributeType]) as IPropertyGirdCell);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        public void ShouldReturnNoPropertyEditorByAttributes()
        {
            Assert.IsNull(EditorCollection.GetPropertyEditorByAttributes(null));
            Assert.IsNull(EditorCollection.GetPropertyEditorByAttributes(new AttributeCollection()));

            PropertyEditorAttribute attribute = new PropertyEditorAttribute(typeof(string));
            Editor editor = EditorCollection.GetPropertyEditorByAttributes(new AttributeCollection(new Attribute[] { attribute }));

            Assert.IsNull(editor);

            attribute = new PropertyEditorAttribute("missing");
            editor    = EditorCollection.GetPropertyEditorByAttributes(new AttributeCollection(new Attribute[] { attribute }));
            Assert.IsNull(editor);

            attribute = new PropertyEditorAttribute(typeof(InvalidPropertyEditorMock));
            editor    = EditorCollection.GetPropertyEditorByAttributes(new AttributeCollection(new Attribute[] { attribute }));
            Assert.IsNull(editor);
        }
 public IPropertyGirdCell Create(PropertyEditorAttribute attribute)
 {
     return(_factory.Create(attribute));
 }
Пример #7
0
        public void ShouldReturnEqualtyForSameInstance()
        {
            PropertyEditorAttribute attribute = new PropertyEditorAttribute("type");

            Assert.IsTrue(attribute.Equals(attribute));
        }
Пример #8
0
        public void ShouldAssignType()
        {
            PropertyEditorAttribute attribute = new PropertyEditorAttribute(typeof(string));

            Assert.AreEqual <string>(typeof(string).AssemblyQualifiedName, attribute.EditorType);
        }
Пример #9
0
        public void ShouldAssignTypeName()
        {
            PropertyEditorAttribute attribute = new PropertyEditorAttribute("TYPE");

            Assert.AreEqual <string>("TYPE", attribute.EditorType);
        }
Пример #10
0
 internal ProjectDataProperty(PropertyEditorAttribute attr, PropertyInfo p)
 {
     Attr = attr;
     P    = p;
 }