示例#1
0
        public void EqualsGetHashCodeAndEqualityOperators()
        {
            var a = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, SourceId);
            var b = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, SourceId);
            var c = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, SourceId);

            var otherCommandId      = new EmployeeImported(Guid.NewGuid(), EmployeeNumber + 1, FirstName, Lastname, SourceId);
            var otherEmployeeNumber = new EmployeeImported(Id, EmployeeNumber + 1, FirstName, Lastname, SourceId);
            var otherFirstName      = new EmployeeImported(Id, EmployeeNumber, FirstName + "x", Lastname, SourceId);
            var otherFirstNameNull  = new EmployeeImported(Id, EmployeeNumber, null, Lastname, SourceId);
            var otherLastName       = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname + "x", SourceId);
            var otherLastNameNull   = new EmployeeImported(Id, EmployeeNumber, FirstName, null, SourceId);
            var otherSourceId       = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, SourceId + 1);
            var otherSourceIdNull   = new EmployeeImported(Id, EmployeeNumber, FirstName, Lastname, null);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c,
                                                     otherCommandId,
                                                     otherEmployeeNumber, otherFirstName, otherFirstNameNull,
                                                     otherLastName, otherLastNameNull,
                                                     otherSourceId, otherSourceIdNull);

            EqualityTesting.TestEqualityOperators(a, b, c,
                                                  otherEmployeeNumber, otherFirstName, otherFirstNameNull,
                                                  otherLastName, otherLastNameNull,
                                                  otherSourceId, otherSourceIdNull);
        }
示例#2
0
        public void EqualsGetHashCodeAndEqualityOperators()
        {
            var id          = Guid.NewGuid();
            var aliceAndBob = new[]
            {
                new Name("Alice", "Crypto"),
                new Name("Bob", "Crypto")
            };
            var coryAndDan = new[]
            {
                new Name("Cory", "Crypto"),
                new Name("Dan", "Crypto")
            };

            var a = new DepartmentImported(id, aliceAndBob);
            var b = new DepartmentImported(id, aliceAndBob);
            var c = new DepartmentImported(id, aliceAndBob);

            var otherNamesSameCount             = new DepartmentImported(id, coryAndDan);
            var otherNamesDifferentCount        = new DepartmentImported(id, new[] { aliceAndBob[0] });
            var otherNamesNull                  = new DepartmentImported(id, null);
            var otherNamesSameCountNullElements = new DepartmentImported(id, new Name[] { null, null });

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c,
                                                     otherNamesSameCount,
                                                     otherNamesDifferentCount,
                                                     otherNamesNull,
                                                     otherNamesSameCountNullElements);

            EqualityTesting.TestEqualityOperators(a, b, c,
                                                  otherNamesSameCount,
                                                  otherNamesDifferentCount,
                                                  otherNamesNull,
                                                  otherNamesSameCountNullElements);
        }
示例#3
0
        public void EqualsAndGetHashCodeAndEquality()
        {
            var a = new Keyword("a");
            var b = new Keyword("a");
            var c = new Keyword("a");

            var otherName = new Keyword("b");

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherName);
            EqualityTesting.TestEqualityOperators(a, b, c, otherName);
        }
示例#4
0
        public void EqualityOperations()
        {
            var a = new TypeName("name");
            var b = new TypeName("name");
            var c = new TypeName("name");

            var otherName = new TypeName("other name");

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherName);
            EqualityTesting.TestEqualityOperators(a, b, c, otherName);
        }
        public void EqualsGetHashCodeAndEqualityOperators()
        {
            var a = new Generated.EmployeeMetadata(Source, SourceId);
            var b = new Generated.EmployeeMetadata(Source, SourceId);
            var c = new Generated.EmployeeMetadata(Source, SourceId);

            var otherSource       = new Generated.EmployeeMetadata(Source + "x", SourceId);
            var otherSourceId     = new Generated.EmployeeMetadata(Source, SourceId + 1);
            var otherSourceIdNull = new Generated.EmployeeMetadata(Source, null);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherSource, otherSourceId, otherSourceIdNull);
            EqualityTesting.TestEqualityOperators(a, b, c, otherSource, otherSourceId, otherSourceIdNull);
        }
示例#6
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 CommandConventions(baseTypes);
            var b = new CommandConventions(baseTypes);
            var c = new CommandConventions(baseTypes);

            var otherBaseTypes = new CommandConventions(anotherContractBaseTypes);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherBaseTypes);
            EqualityTesting.TestEqualityOperators(a, b, c, otherBaseTypes);
        }
示例#7
0
        public void EqualsGetHashCodeAndEqualityOperators()
        {
            const int number = 1;

            var a = new Generated.EmployeeNumber(number);
            var b = new Generated.EmployeeNumber(number);
            var c = new Generated.EmployeeNumber(number);

            var otherEmployeeNumber = new Generated.EmployeeNumber(number + 1);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherEmployeeNumber);

            EqualityTesting.TestEqualityOperators(a, b, c, otherEmployeeNumber);
        }
示例#8
0
        public void EqualsGetHashCodeAndEqualityOperators()
        {
            const string first = "Joe";
            const string last  = "User";

            var a = new Generated.EmployeeName(first, last);
            var b = new Generated.EmployeeName(first, last);
            var c = new Generated.EmployeeName(first, last);

            var otherFirstName = new Generated.EmployeeName(first + "x", last);
            var otherLastName  = new Generated.EmployeeName(first, "von " + last);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherFirstName, otherLastName);
            EqualityTesting.TestEqualityOperators(a, b, c, otherFirstName, otherLastName);
        }
        public void EqualsGetHashCodeAndEqualityOperators_TypeWithStringReferenceTypeArray_ShouldWork()
        {
            const int number = 1;
            var       roles  = new[] { "tester", "developer" };

            var a = new Generated.EmployeeRoles(number, roles);
            var b = new Generated.EmployeeRoles(number, new[] { "tester", "developer" });
            var c = new Generated.EmployeeRoles(number, roles);

            var otherEmployeeNumber = new Generated.EmployeeRoles(number + 1, roles);
            var otherRolesLength    = new Generated.EmployeeRoles(number, new[] { "tester" });
            var otherRolesValues    = new Generated.EmployeeRoles(number, new[] { "tester", "analyst" });

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherEmployeeNumber, otherRolesLength, otherRolesValues);
            EqualityTesting.TestEqualityOperators(a, b, c, otherEmployeeNumber, otherRolesLength, otherRolesValues);
        }
示例#10
0
        public void EqualityOperations()
        {
            var typeNameBaseType      = new TypeName("SomeNamespace.IBaseType");
            var typeNameOtherBaseType = new TypeName("SomeNamespace.IOtherBaseType");

            var a = new BaseTypes(new[] { typeNameBaseType });
            var b = new BaseTypes(new[] { typeNameBaseType });
            var c = new BaseTypes(new[] { typeNameBaseType });

            var otherTypeName       = new BaseTypes(new[] { typeNameOtherBaseType });
            var otherTypeNameLength = new BaseTypes(new[] { typeNameBaseType, typeNameOtherBaseType });
            var otherTypeNameNull   = new BaseTypes(null);

            EqualityTesting.TestEqualityOperators(a, b, c, otherTypeName, otherTypeNameLength, otherTypeNameNull);
            EqualityTesting.TestEqualityOperators(a, b, c, otherTypeName, otherTypeNameLength, otherTypeNameNull);
        }
        public void EqualsGetHashCodeAndEqualityOperators_TypeWithValueTypeArray_ShouldWork()
        {
            const int number  = 1;
            var       ratings = new[] { 1, 2 };

            var a = new Generated.EmployeeRatings(number, ratings);
            var b = new Generated.EmployeeRatings(number, new[] { 1, 2 });
            var c = new Generated.EmployeeRatings(number, new[] { 1, 2 });

            var otherEmployeeNumber = new Generated.EmployeeRatings(number + 1, ratings);
            var otherRatingsLength  = new Generated.EmployeeRatings(number, new[] { 1 });
            var otherRatingsValues  = new Generated.EmployeeRatings(number, new[] { 1, 3 });
            var otherRatingsOrder   = new Generated.EmployeeRatings(number, new[] { 2, 1 });
            var otherRatingsNull    = new Generated.EmployeeRatings(number, null);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherEmployeeNumber, otherRatingsLength, otherRatingsValues, otherRatingsOrder, otherRatingsNull);
            EqualityTesting.TestEqualityOperators(a, b, c, otherEmployeeNumber, otherRatingsLength, otherRatingsValues, otherRatingsOrder, otherRatingsNull);
        }
        public void EqualsGetHashCodeAndEqualityOperators()
        {
            var alice = new Name("Alice", "Crypto");
            var bob   = new Name("Bob", "Crypto");

            var a = new NamedPerson(alice, Gender.Female);
            var b = new NamedPerson(alice, Gender.Female);
            var c = new NamedPerson(alice, Gender.Female);

            var otherName       = new NamedPerson(bob, Gender.Female);
            var otherGenderNull = new NamedPerson(alice, null);
            var otherGenderMale = new NamedPerson(alice, Gender.Male);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c,
                                                     otherName, otherGenderNull, otherGenderMale);
            EqualityTesting.TestEqualityOperators(a, b, c,
                                                  otherName, otherGenderNull, otherGenderMale);
        }
示例#13
0
        public void EqualsGetHashCodeAndEqualityOperators()
        {
            var a = new Name(FirstName, Lastname);
            var b = new Name(FirstName, Lastname);
            var c = new Name(FirstName, Lastname);

            var otherFirstName     = new Name(FirstName + "x", Lastname);
            var otherFirstNameNull = new Name(null, Lastname);
            var otherLastName      = new Name(FirstName, Lastname + "x");
            var otherLastNameNull  = new Name(FirstName, null);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c,
                                                     otherFirstName, otherFirstNameNull,
                                                     otherLastName, otherLastNameNull);

            EqualityTesting.TestEqualityOperators(a, b, c,
                                                  otherFirstName, otherFirstNameNull,
                                                  otherLastName, otherLastNameNull);
        }
示例#14
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);
        }
        public void EqualsAndGetHashCode()
        {
            var          id     = Guid.NewGuid();
            const int    number = 1;
            var          name   = new Name("Alice", "Crypto");
            const Gender gender = Gender.Female;

            var a = new ImportEmployeeNestedTypes(id, number, name, gender);
            var b = new ImportEmployeeNestedTypes(id, number, name, gender);
            var c = new ImportEmployeeNestedTypes(id, number, name, gender);

            var otherId        = new ImportEmployeeNestedTypes(Guid.NewGuid(), number, name, gender);
            var otherNumber    = new ImportEmployeeNestedTypes(id, number + 1, name, gender);
            var otherNameNull  = new ImportEmployeeNestedTypes(id, number, null, gender);
            var otherNameFirst = new ImportEmployeeNestedTypes(id, number, new Name("Bob", "Crypto"), gender);
            var otherNameLast  = new ImportEmployeeNestedTypes(id, number, new Name("Alice", "Newlywed"), gender);
            var otherGender    = new ImportEmployeeNestedTypes(id, number, name, Gender.Male);

            EqualityTesting.TestEqualsAndGetHashCode(a, b, c, otherId, otherNumber, otherNameNull, otherNameFirst, otherNameLast, otherGender);
            EqualityTesting.TestEqualityOperators(a, b, c, otherId, otherNumber, otherNameNull, otherNameFirst, otherNameLast, otherGender);
        }