示例#1
0
        public void TestNoAttribute()
        {
            // simply ignore
            var source = @"
class C { }
";
            var generatorDiagnostics = GeneratorTestFactory.RunGenerator(source);

            Assert.False(generatorDiagnostics.Any(x => x.Severity == DiagnosticSeverity.Error));
        }
示例#2
0
        public void GeneratesEmptyInterface()
        {
            var source = @"
using AutomaticInterfaceAttribute;

namespace AutomaticInterfaceExample
{
    [GenerateAutomaticInterface]
    class DemoClass
    {
    }
}
";
            var generatorDiagnostics = GeneratorTestFactory.RunGenerator(source);

            Assert.False(generatorDiagnostics.Any(x => x.Severity == DiagnosticSeverity.Error));
        }
示例#3
0
        public void GeneratesStringPropertySetOnlyInterface()
        {
            var source = @"
using AutomaticInterfaceAttribute;

namespace AutomaticInterfaceExample
{
    [GenerateAutomaticInterface]
    class DemoClass
    {
        string _hello;
        public string Hello { set => _hello = value; }
    }
}
";
            var generatorDiagnostics = GeneratorTestFactory.RunGenerator(source);

            Assert.False(generatorDiagnostics.Any(x => x.Severity == DiagnosticSeverity.Error), string.Join("\n", generatorDiagnostics));
        }