Beispiel #1
0
        public void AttributeWithConstructorArguments()
        {
            //-- arrange

            var attribute = new AttributeDescription()
            {
                AttributeType = typeof(TestAttributes.AttributeOne)
            };

            attribute.ConstructorArguments.Add(new ConstantExpression()
            {
                Value = 123
            });
            attribute.ConstructorArguments.Add(new ConstantExpression()
            {
                Value = "ABC"
            });

            //-- act

            var syntax = AttributeSyntaxEmitter.EmitSyntax(attribute);

            //-- assert

            syntax.Should().BeEquivalentToCode("TestAttributes.AttributeOne(123, \"ABC\")");
        }
Beispiel #2
0
        public void AttributeWithPropertyValues()
        {
            //-- arrange

            var attribute = new AttributeDescription()
            {
                AttributeType = typeof(TestAttributes.AttributeOne)
            };

            attribute.PropertyValues.Add(new PropertyValue()
            {
                Name = "First", Value = new ConstantExpression()
                {
                    Value = 123
                }
            });
            attribute.PropertyValues.Add(new PropertyValue()
            {
                Name = "Second", Value = new ConstantExpression()
                {
                    Value = "ABC"
                }
            });

            //-- act

            var syntax = AttributeSyntaxEmitter.EmitSyntax(attribute);

            //-- assert

            syntax.Should().BeEquivalentToCode("TestAttributes.AttributeOne(First = 123, Second = \"ABC\")");
        }
Beispiel #3
0
        public void AttributeWithNoValues()
        {
            //-- arrange

            var attribute = new AttributeDescription()
            {
                AttributeType = typeof(TestAttributes.AttributeOne)
            };

            //-- act

            var syntax = AttributeSyntaxEmitter.EmitSyntax(attribute);

            //-- assert

            syntax.Should().BeEquivalentToCode("TestAttributes.AttributeOne");
        }