Exemplo n.º 1
0
        public void Override_WithNull_ShouldReturnSameInstance()
        {
            var instance = new DomainEventConventions(new BaseTypes(new TypeName[] { }));
            var actual   = instance.ApplyOverridesFrom(null);

            Assert.That(actual, Is.SameAs(instance));
        }
Exemplo n.º 2
0
        public void Override_WithEmptyBaseTypes_ShouldReturnInstanceWithEmptyBaseTypes()
        {
            var instance = new DomainEventConventions(
                new BaseTypes(new[] { new TypeName("Foo.EventBase") }));
            var actual = instance.ApplyOverridesFrom(
                new DomainEventConventions(new BaseTypes(new TypeName[] { })));

            Assert.That(actual.BaseTypes, Is.EqualTo(new BaseTypes(new TypeName[0])));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        public void EqualityMethods()
        {
            var baseTypes = new BaseTypes(new[] { new TypeName("SomeNamespace.IContract") });
            var anotherContractBaseTypes = new BaseTypes(new[] { new TypeName("SomeNamespace.IAnotherContract") });

            var a = new DomainEventConventions(baseTypes);
            var b = new DomainEventConventions(baseTypes);
            var c = new DomainEventConventions(baseTypes);

            var otherBaseTypes = new DomainEventConventions(anotherContractBaseTypes);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherBaseTypes);
            EqualityTesting.TestEqualityOperators(a, b, c, otherBaseTypes);
        }
Exemplo n.º 5
0
        public static CodeTypeDeclaration CreateDomainEventDeclaration(
            SemanticModel model, NamespaceName namespaceName,
            DomainEventDeclaration declaration,
            DomainEventConventions conventions)
        {
            var type = CreateTypeWithValueSemantics(
                ValueObjectSpecification.CreateClass(
                    namespaceName, declaration.Name,
                    declaration.Properties.ToArray(),
                    conventions.BaseTypes,
                    true, true),
                model.KnownTypes);

            return(type);
        }
Exemplo 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));
        }
Exemplo n.º 7
0
        public void Override_WithNewBaseTypes_ShouldReturnInstanceWithNewBaseTypes()
        {
            var instance = new DomainEventConventions(
                new BaseTypes(new[] { new TypeName("Foo.EventBase") }));

            var actual = instance.ApplyOverridesFrom(
                new DomainEventConventions(
                    new BaseTypes(
                        new[]
            {
                new TypeName("Bar.EventBase"),
                new TypeName("Bar.IDomainEvent")
            })));

            Assert.That(actual.BaseTypes.TypeNames.Count(), Is.EqualTo(2));
            Assert.That(actual.BaseTypes.TypeNames.SingleOrDefault(x => x.Name == "Bar.EventBase"), Is.Not.Null);
            Assert.That(actual.BaseTypes.TypeNames.SingleOrDefault(x => x.Name == "Bar.IDomainEvent"), Is.Not.Null);
        }
Exemplo n.º 8
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);
        }