ClassRecordGeneratorTests.cs 934 B

1234567891011121314151617181920212223242526272829
  1. using CodeGenerators;
  2. using Microsoft.CodeAnalysis.CSharp;
  3. namespace CodeGeneratorsTests;
  4. public class ClassRecordGeneratorTests
  5. {
  6. [Fact]
  7. public void BuildTest()
  8. {
  9. var test = new ClassRecordGenerator("TestNamespace", "Test");
  10. test.Usings.Add("ExcelORM");
  11. var property = new Property("TestProperty", "string");
  12. property.Attributes.Add(new AttributeElement("Column", "Test Property"));
  13. test.Properties.Add(property.Name, property);
  14. var secondProperty = new Property("SecondProperty", "int");
  15. secondProperty.Attributes.Add(new AttributeElement("Column", "Second Property"));
  16. test.Properties.Add(secondProperty.Name, secondProperty);
  17. var result = test.Build();
  18. Assert.NotEmpty(result);
  19. var tree = CSharpSyntaxTree.ParseText(result);
  20. var diag = tree.GetDiagnostics();
  21. Assert.False(diag.Any());
  22. }
  23. }