Exemplo n.º 1
0
            public void ShouldNotBeEqualWhenEntitiesAreDifferent()
            {
                // arrange
                var targetId               = Faker.Random.Int();
                var stronglyTypedId        = new IntFor <Order>(targetId);
                var anotherStronglyTypedId = new IntFor <PricePosition>(targetId);

                // act
                var result = stronglyTypedId.Equals(anotherStronglyTypedId);

                // assert
                result.Should().BeFalse();
            }
Exemplo n.º 2
0
            public void ShouldNotBeEqualWithIEntityIdWhenNull()
            {
                // arrange
                var targetId        = Faker.Random.Int();
                var stronglyTypedId = new IntFor <Order>(targetId);
                IEntityId <Order, int> anotherStronglyTypedId = null;

                // act
                var result = stronglyTypedId.Equals(anotherStronglyTypedId);

                // assert
                result.Should().BeFalse();
            }
Exemplo n.º 3
0
            public void ShouldBeEqualWhenValuesAndEntitiesAreEqual()
            {
                // arrange
                var targetId               = Faker.Random.Int();
                var stronglyTypedId        = new IntFor <Order>(targetId);
                var anotherStronglyTypedId = new IntFor <Order>(targetId);

                // act
                var result = stronglyTypedId.Equals(anotherStronglyTypedId);

                // assert
                result.Should().BeTrue();
            }
Exemplo n.º 4
0
            public void ShouldProvide1WhenCompareToNullEntityId()
            {
                // arrange
                var targetId        = Faker.Random.Int();
                var stronglyTypedId = new IntFor <Order>(targetId);


                // act
                var result = stronglyTypedId.CompareTo((IEntityId <Order, int>)null);

                // assert
                result.Should().Be(1);
            }
            public void ShouldNotProvideSameHashCodeWhenValuesAreDifferent()
            {
                // arrange
                var stronglyTypedId        = new IntFor <Order>(Faker.Random.Int());
                var anotherStronglyTypedId = new IntFor <Order>(Faker.Random.Int());

                // act
                var hashCode1 = stronglyTypedId.GetHashCode();
                var hashCode2 = anotherStronglyTypedId.GetHashCode();

                // assert
                hashCode1.Should().NotBe(hashCode2);
            }
Exemplo n.º 6
0
            public void ShouldProvide0ForSameBaseId()
            {
                // arrange
                var targetId               = Faker.Random.Int();
                var stronglyTypedId        = new IntFor <Order>(targetId);
                var anotherStronglyTypedId = new IntFor <Order>(targetId);

                // act
                var result = stronglyTypedId.CompareTo(anotherStronglyTypedId);

                // assert
                result.Should().Be(0);
            }
Exemplo n.º 7
0
            public void ShouldThrowWhenCompareWithNoEntityId()
            {
                // arrange
                var targetId        = Faker.Random.Int();
                var stronglyTypedId = new IntFor <Order>(targetId);
                var someObject      = new Order();

                // act
                Func <int> act = () => stronglyTypedId.CompareTo(someObject);

                // assert
                act.Should().Throw <ArgumentException>();
            }
            public void ShouldNotProvideSameHashCodeWhenEntitiesAreDifferent()
            {
                // arrange
                var targetId               = Faker.Random.Int();
                var stronglyTypedId        = new IntFor <Order>(targetId);
                var anotherStronglyTypedId = new IntFor <PricePosition>(targetId);

                // act
                var hashCode1 = stronglyTypedId.GetHashCode();
                var hashCode2 = anotherStronglyTypedId.GetHashCode();

                // assert
                hashCode1.Should().NotBe(hashCode2);
            }
            public void ShouldProvideSameHashCodeWhenValuesAndEntitiesAreEqual()
            {
                // arrange
                var targetId               = Faker.Random.Int();
                var stronglyTypedId        = new IntFor <Order>(targetId);
                var anotherStronglyTypedId = new IntFor <Order>(targetId);

                // act
                var hashCode1 = stronglyTypedId.GetHashCode();
                var hashCode2 = anotherStronglyTypedId.GetHashCode();

                // assert
                hashCode1.Should().Be(hashCode2);
            }
Exemplo n.º 10
0
            public void ShouldProvideSameResultAsBaseIdsDoForEntityId()
            {
                // arrange
                var stronglyTypedId        = new IntFor <Order>(Faker.Random.Int());
                var anotherStronglyTypedId = new IntFor <Order>(Faker.Random.Int());

                // act
                var result1 = stronglyTypedId.CompareTo((IEntityId <Order, int>)anotherStronglyTypedId);
                var result2 = anotherStronglyTypedId.CompareTo((IEntityId <Order, int>)stronglyTypedId);

                var baseResult1 = stronglyTypedId.Value.CompareTo(anotherStronglyTypedId.Value);
                var baseResult2 = anotherStronglyTypedId.Value.CompareTo(stronglyTypedId.Value);

                // assert
                result1.Should().Be(baseResult1);
                result2.Should().Be(baseResult2);
            }