コード例 #1
0
        public void GivenNullNameGetterWhenCreateAttributeDefinitionThenFail()
        {
            // arrange
            var type  = typeof(TestAttributeChecked);
            var value = new TestAttributeChecked();
            var xml   = new TestAttributeXml();

            // act && assert
            Assert.Throws <ArgumentNullException>(() => new AttributeDefinition(type, value, null, xml));
        }
コード例 #2
0
        public void GivenNullValueWhenCreateAttributeDefinitionThenFail()
        {
            // arrange
            var type = typeof(TestAttributeChecked);
            Func <ILanguage, string> nameGetter = language => _attributeName;
            var xml = new TestAttributeXml();

            // act && assert
            Assert.Throws <ArgumentNullException>(() => new AttributeDefinition(type, null, nameGetter, xml));
        }
コード例 #3
0
        public void GivenWrongTypeValueWhenCreateAttributeDefinitionThenFail()
        {
            // arrange
            var type       = typeof(TestAttributeChecked);
            var wrongValue = Modules.Boolean.Attributes.IsBooleanAttribute.Value;
            Func <ILanguage, string> nameGetter = language => _attributeName;
            var xml = new TestAttributeXml();

            // act && assert
            Assert.Throws <InvalidCastException>(() => new AttributeDefinition(type, wrongValue, nameGetter, xml));
        }
コード例 #4
0
        public void GivenDerivedTypeValueWhenCreateAttributeDefinitionThenSucceed()
        {
            // arrange
            var type  = typeof(TestAttributeChecked);
            var value = new TestAttributeDerived();
            Func <ILanguage, string> nameGetter = language => _attributeName;
            var xml = new TestAttributeXml();

            // act
            var attribute = new AttributeDefinition(type, value, nameGetter, xml);

            // assert
            Assert.AreSame(type, attribute.Type);
            Assert.AreSame(value, attribute.AttributeValue);
            Assert.AreEqual(_attributeName, attribute.GetName(null));
        }