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\")"); }
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\")"); }
public void AttributeWithNoValues() { //-- arrange var attribute = new AttributeDescription() { AttributeType = typeof(TestAttributes.AttributeOne) }; //-- act var syntax = AttributeSyntaxEmitter.EmitSyntax(attribute); //-- assert syntax.Should().BeEquivalentToCode("TestAttributes.AttributeOne"); }