public void DomainEventDeclaration_WithNestedDto_DtoArray_ShouldCompile() { var dtoDeclaration = new DtoDeclaration( "EmployeeName", new[] { new PropertyDeclaration("First", new StringReferenceType()), new PropertyDeclaration("Last", new StringReferenceType()), }); var eventDeclaration = new DomainEventDeclaration( "DepartmentImported", new[] { new PropertyDeclaration( "DepartmentNumber", new SimpleType(typeof(int))), new PropertyDeclaration( "Employees", new ArrayType(new TypeName("EmployeeName"), new RankSpecifiers(new [] { new RankSpecifier(1) })) ) }); var model = CreateSemanticModelWith(dtoDeclaration, eventDeclaration); var actual = CodeDomCompiler.Compile(model); var source = CompileToSource(actual); Assert.That(source, Is.StringMatching(@"EmployeeName\[\]\s+Employees")); }
public static CodeTypeDeclaration CreateDtoDeclaration( SemanticModel model, NamespaceName namespaceName, DtoDeclaration declaration) { return(CreateTypeWithValueSemantics( ValueObjectSpecification.CreateClass( namespaceName, declaration.Name, declaration.Properties.ToArray(), new BaseTypes(new TypeName[0]), true, true), model.KnownTypes)); }
public void DtoDeclaration_WithNestedDto_Enum_ShouldCompile() { var enumDeclaration = new EnumDeclaration("Role", new[] { "Tester", "Developer" }); var employeeInfoDto = new DtoDeclaration( "EmployeeInfo", new[] { new PropertyDeclaration("EmployeeRole", new TypeName("Role")) } ); var source = CompileToSource(CodeDomCompiler .Compile(CreateSemanticModelWith(enumDeclaration, employeeInfoDto))); Assert.That(source, Is.StringMatching(@"public\s+Role\s+EmployeeRole")); }
public void DtoDeclaration_WithNestedDto_Dto_ShouldCompile() { var nameDto = CreateNameDtoDeclaration(); var employeeInfoDto = new DtoDeclaration( "EmployeeInfo", new[] { new PropertyDeclaration("EmployeeName", new TypeName("Name")) } ); var source = CompileToSource(CodeDomCompiler .Compile(CreateSemanticModelWith(nameDto, employeeInfoDto))); Assert.That(source, Is.StringMatching(@"public\s+Name\s+EmployeeName")); }
public void CommandDeclaration_WithNestedDto_Dto_ShouldCompile() { var dtoDeclaration = new DtoDeclaration("AmountDto", new[] { new PropertyDeclaration("Amount", new SimpleType(typeof(decimal))) }); var commandDeclaration = new CommandDeclaration("ImportEmployeeCommand", new[] { new PropertyDeclaration("EmployeeNumber", new SimpleType(typeof(int))), new PropertyDeclaration("Salary", new TypeName("AmountDto")) }); var model = CreateSemanticModelWith(dtoDeclaration, commandDeclaration); var actual = CodeDomCompiler.Compile(model); Assert.That(actual, Is.Not.Null); var source = CompileToSource(actual); Assert.That(source, Is.StringContaining("class ImportEmployeeCommand")); Assert.That(source, Is.StringMatching(@"public.*AmountDto\s+Salary")); }
public void Visit(DtoDeclaration node) { var fullName = FullName(node.Name); _knownTypes.Add(new KnownType(fullName, false)); }
private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, DtoDeclaration declaration) { ns.Types.Add(DtoGenerator.CreateDtoDeclaration(model, namespaceName, declaration)); }
public virtual DtoDeclaration Transform(DtoDeclaration declaration) { return(declaration); }