Esempio n. 1
0
 private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, ApplicationServiceDeclaration declaration)
 {
     ns.Types.Add(ApplicationServiceGenerator.CreateApplicationServiceInterface(declaration));
     foreach (var command in declaration.Commands)
     {
         Add(ns, conventions, model, namespaceName, command);
     }
 }
Esempio n. 2
0
        public void ApplyOverrides_WithNullConventions_ShouldReturnEqualInstance()
        {
            var domainEventsConventions = new DomainEventConventions(new BaseTypes(new TypeName[] {}));
            var commandConventions      = new CommandConventions(new BaseTypes(new TypeName[] {}));
            var instance = new ConventionsDeclaration(domainEventsConventions, commandConventions);

            var actual = instance.ApplyOverridesFrom(new ConventionsDeclaration(null, null));

            Assert.That(actual, Is.EqualTo(instance));
        }
Esempio n. 3
0
        public void CommandDeclaration_WithConventionInheritICommand_ShouldProduceClassInheritingICommand()
        {
            var declaration = CreateImportEmployeeCommandDeclaration();
            var conventions = new ConventionsDeclaration(
                new DomainEventConventions(new BaseTypes(new TypeName[0])),
                new CommandConventions(new BaseTypes(new[] { new TypeName("Test.Diesel.ICommand") })));
            var model  = CreateSemanticModelWith(conventions, declaration);
            var source = CompileToSource(CodeDomCompiler.Compile(model));

            Assert.That(source, Is.StringMatching(@"class ImportEmployeeCommand : Test.Diesel.ICommand"));
        }
Esempio n. 4
0
        private static void Add(CodeCompileUnit codeCompileUnit, ConventionsDeclaration conventions, SemanticModel model, Namespace declaration)
        {
            var ns = new CodeNamespace(declaration.Name.Name);

            ns.Imports.Add(new CodeNamespaceImport("System"));
            codeCompileUnit.Namespaces.Add(ns);
            foreach (var typeDeclaration in declaration.Declarations)
            {
                Add(ns, conventions, model, declaration.Name, (dynamic)typeDeclaration);
            }
        }
Esempio n. 5
0
        private static void Add(CodeCompileUnit codeCompileUnit, ConventionsDeclaration conventions, SemanticModel model, AbstractSyntaxTree ast)
        {
            var userConventions = conventions;

            if (ast.Conventions != null)
            {
                userConventions = conventions.ApplyOverridesFrom(ast.Conventions);
            }
            foreach (var ns in ast.Namespaces)
            {
                Add(codeCompileUnit, userConventions, model, ns);
            }
        }
Esempio n. 6
0
        public void ApplyOverrides_WithNewCommandConventions_ShouldReturnNewInstanceWithThese()
        {
            var domainEventsConventions = new DomainEventConventions(new BaseTypes(new TypeName[] { }));
            var commandConventions      = new CommandConventions(new BaseTypes(new TypeName[] { }));
            var instance = new ConventionsDeclaration(domainEventsConventions, commandConventions);

            var newCommandConventions = new CommandConventions(
                new BaseTypes(new[] { new TypeName("SomeNamespace.ICommand") }));

            var actual = instance.ApplyOverridesFrom(new ConventionsDeclaration(null, newCommandConventions));

            Assert.That(actual, Is.Not.SameAs(instance));
            Assert.That(actual.DomainEventConventions, Is.EqualTo(domainEventsConventions));
            Assert.That(actual.CommandConventions, Is.EqualTo(newCommandConventions));
        }
Esempio n. 7
0
        public void EqualityOperations()
        {
            var domainEventsConventions = new DomainEventConventions(new BaseTypes(new TypeName[] { }));
            var commandConventions      = new CommandConventions(new BaseTypes(new TypeName[] { }));

            var a = new ConventionsDeclaration(domainEventsConventions, commandConventions);
            var b = new ConventionsDeclaration(domainEventsConventions, commandConventions);
            var c = new ConventionsDeclaration(domainEventsConventions, commandConventions);

            var otherDomainEvents = new ConventionsDeclaration(
                new DomainEventConventions(new BaseTypes(new[] { new TypeName("Some.BaseType") })),
                commandConventions);
            var otherCommands = new ConventionsDeclaration(
                domainEventsConventions,
                new CommandConventions(new BaseTypes(new[] { new TypeName("Some.BaseType") })));

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherDomainEvents, otherCommands);
            EqualityTesting.TestEqualityOperators(a, b, c, otherDomainEvents, otherCommands);
        }
Esempio n. 8
0
        private SemanticModel CreateSemanticModelWith(ConventionsDeclaration conventions, params TypeDeclaration[] typeDeclarations)
        {
            var ns = new NamespaceName(typeof(CodeDomCompilerTest).Namespace + ".Generated");

            return(new SemanticModel(new AbstractSyntaxTree(conventions, new[] { new Namespace(ns, typeDeclarations) })));
        }
Esempio n. 9
0
 public void Visit(ConventionsDeclaration node)
 {
 }
Esempio n. 10
0
 private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, EnumDeclaration declaration)
 {
     ns.Types.Add(EnumGenerator.CreateEnumDeclaration(declaration));
 }
Esempio n. 11
0
 private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, DtoDeclaration declaration)
 {
     ns.Types.Add(DtoGenerator.CreateDtoDeclaration(model, namespaceName, declaration));
 }
Esempio n. 12
0
 private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, DomainEventDeclaration declaration)
 {
     ns.Types.Add(DomainEventGenerator.CreateDomainEventDeclaration(model, namespaceName, declaration, conventions.DomainEventConventions));
 }
Esempio n. 13
0
 private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, CommandDeclaration declaration)
 {
     ns.Types.Add(CommandGenerator.CreateCommandDeclaration(model, namespaceName, declaration, conventions.CommandConventions));
 }
Esempio n. 14
0
 private static void Add(CodeCompileUnit codeCompileUnit, ConventionsDeclaration conventions, SemanticModel model)
 {
     Add(codeCompileUnit, conventions, model, model.AbstractSyntaxTree);
 }
Esempio n. 15
0
 private ConventionsDeclaration Transform(ConventionsDeclaration conventions)
 {
     return(conventions);
 }