예제 #1
0
        public void EmptyDataTest()
        {
            var generator = new AttributeGenerator();
            var result    = generator.Generate(new Type[0]);

            Assert.AreEqual("", result);
        }
예제 #2
0
        public void SingleAttributeTypeDataTest()
        {
            var generator  = new AttributeGenerator();
            var attributes = new[] { typeof(System.ComponentModel.DataAnnotations.RequiredAttribute) };
            var result     = generator.Generate(attributes);

            Assert.AreEqual("[System.ComponentModel.DataAnnotations.RequiredAttribute]", result);
        }
예제 #3
0
        public void Generate_GivenCustomAttributeData_WithoutNamedArgument_GenerateAttributeAsString()
        {
            var stringAttribute = _sut.Generate(typeof(AttributeHost).GetCustomAttributesData().First());

            Assert.Equal("[RequestHandlers.Mvc.Tests.CSharp.TestNamedArgumentsAttribute]", stringAttribute);
        }
예제 #4
0
        public void InvalidDataTypeTest()
        {
            var generator = new AttributeGenerator();

            Assert.Throws(typeof(InvalidOperationException), () => generator.Generate(123));
        }
예제 #5
0
        public void NullDataTest()
        {
            var generator = new AttributeGenerator();

            Assert.Throws(typeof(ArgumentNullException), () => generator.Generate(null));
        }
예제 #6
0
        public string LiteralDataTest(string data)
        {
            var generator = new AttributeGenerator();

            return(generator.Generate(data));
        }