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); } }
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)); }
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")); }
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); } }
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); } }
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)); }
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); }
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) }))); }
public void Visit(ConventionsDeclaration node) { }
private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, EnumDeclaration declaration) { ns.Types.Add(EnumGenerator.CreateEnumDeclaration(declaration)); }
private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, DtoDeclaration declaration) { ns.Types.Add(DtoGenerator.CreateDtoDeclaration(model, namespaceName, declaration)); }
private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, DomainEventDeclaration declaration) { ns.Types.Add(DomainEventGenerator.CreateDomainEventDeclaration(model, namespaceName, declaration, conventions.DomainEventConventions)); }
private static void Add(CodeNamespace ns, ConventionsDeclaration conventions, SemanticModel model, NamespaceName namespaceName, CommandDeclaration declaration) { ns.Types.Add(CommandGenerator.CreateCommandDeclaration(model, namespaceName, declaration, conventions.CommandConventions)); }
private static void Add(CodeCompileUnit codeCompileUnit, ConventionsDeclaration conventions, SemanticModel model) { Add(codeCompileUnit, conventions, model, model.AbstractSyntaxTree); }
private ConventionsDeclaration Transform(ConventionsDeclaration conventions) { return(conventions); }