ClassRecordGeneratorTests.cs 1.0 KB

12345678910111213141516171819202122232425262728293031
  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 Class Name");
  10. test.Usings.Add("ExcelORM");
  11. const string firstPropertyName = "test Property";
  12. var property = new Property(firstPropertyName, "string");
  13. property.Attributes.Add(new AttributeElement("Column", firstPropertyName));
  14. test.Properties.Add(property.Name, property);
  15. const string secondPropertyName = "second Property";
  16. var secondProperty = new Property(secondPropertyName, "int");
  17. secondProperty.Attributes.Add(new AttributeElement("Column", secondPropertyName));
  18. test.Properties.Add(secondProperty.Name, secondProperty);
  19. var result = test.Build();
  20. Assert.NotEmpty(result);
  21. var tree = CSharpSyntaxTree.ParseText(result);
  22. var diag = tree.GetDiagnostics();
  23. Assert.False(diag.Any());
  24. }
  25. }