Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
        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"));
        }
Ejemplo n.º 4
0
        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"));
        }
Ejemplo n.º 5
0
        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"));
        }
Ejemplo n.º 6
0
        public void Visit(DtoDeclaration node)
        {
            var fullName = FullName(node.Name);

            _knownTypes.Add(new KnownType(fullName, false));
        }
Ejemplo n.º 7
0
 private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, DtoDeclaration declaration)
 {
     ns.Types.Add(DtoGenerator.CreateDtoDeclaration(model, namespaceName, declaration));
 }
Ejemplo n.º 8
0
 public virtual DtoDeclaration Transform(DtoDeclaration declaration)
 {
     return(declaration);
 }