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));
        }
        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));
        }
        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));
        }
        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));
        }