public void Override_WithNull_ShouldReturnSameInstance() { var instance = new DomainEventConventions(new BaseTypes(new TypeName[] { })); var actual = instance.ApplyOverridesFrom(null); Assert.That(actual, Is.SameAs(instance)); }
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]))); }
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 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); }
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); }
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 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); }
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); }