Exemplo n.º 1
0
            public void ShouldNotThrowWhenValueIsNull()
            {
                // arrange
                var stronglyTypedId = new IdFor <Order, object>(null);

                // act
                Func <string> act = () => stronglyTypedId.ToString();

                // assert
                act.Should().NotThrow();
            }
Exemplo n.º 2
0
            public void ShouldNotBeEqualWithIEntityIdWhenValuesAreDifferent()
            {
                // arrange
                var stronglyTypedId        = new IntFor <Order>(Faker.Random.Int());
                var anotherStronglyTypedId = new IdFor <Order, int>(Faker.Random.Int());

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

                // assert
                result.Should().BeFalse();
            }
Exemplo n.º 3
0
            public void ShouldNotBeEqualWhenValuesAreDifferent()
            {
                // arrange
                var stronglyTypedId        = new IdFor <Order, Guid>(Guid.NewGuid());
                var anotherStronglyTypedId = new IdFor <Order, Guid>(Guid.NewGuid());

                // act
                var result = stronglyTypedId == anotherStronglyTypedId;

                // assert
                result.Should().BeFalse();
            }
            public void ShouldNotBeEqualToNull()
            {
                // arrange
                var targetId        = Guid.NewGuid();
                var stronglyTypedId = new IdFor <Order, Guid>(targetId);

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

                // assert
                result.Should().BeFalse();
            }
            public void ShouldNotBeEqualWithIEntityIdWhenValuesAreDifferent()
            {
                // arrange
                var stronglyTypedId        = new LongFor <Order>(Faker.Random.Long());
                var anotherStronglyTypedId = new IdFor <Order, long>(Faker.Random.Long());

                // act
                var result = stronglyTypedId != anotherStronglyTypedId;

                // assert
                result.Should().BeTrue();
            }
            public void ShouldBeEqualWhenIdIsTheSame()
            {
                // arrange
                var targetId        = Guid.NewGuid();
                var stronglyTypedId = new IdFor <Order, Guid>(targetId);

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

                // assert
                result.Should().BeTrue();
            }
Exemplo n.º 7
0
            public void ShouldProvideValueString()
            {
                // arrange
                var targetId        = Guid.NewGuid();
                var stronglyTypedId = new IdFor <Order, Guid>(targetId);

                // act
                var providedValue = stronglyTypedId.ToString();

                // assert
                providedValue.Should().Be(targetId.ToString());
            }
Exemplo n.º 8
0
            public void ShouldBeEqualWithIEntityIdWhenBothNull()
            {
                // arrange
                IdFor <Order, Guid>     stronglyTypedId        = null;
                IEntityId <Order, Guid> anotherStronglyTypedId = null;

                // act
                var result = stronglyTypedId != anotherStronglyTypedId;

                // assert
                result.Should().BeFalse();
            }
Exemplo n.º 9
0
            public void ShouldNotBeEqualWithIEntityIdWhenValuesAreDifferent()
            {
                // arrange
                var stronglyTypedId = new IdFor <Order, Guid>(Guid.NewGuid());
                IEntityId <Order, Guid> anotherStronglyTypedId = new GuidFor <Order>(Guid.NewGuid());

                // act
                var result = stronglyTypedId != anotherStronglyTypedId;

                // assert
                result.Should().BeTrue();
            }
            public void ShouldNotBeEqualWithIEntityIdWhenEntitiesAreDifferent()
            {
                // arrange
                var targetId               = Guid.NewGuid();
                var stronglyTypedId        = new GuidFor <Order>(targetId);
                var anotherStronglyTypedId = new IdFor <PricePosition, Guid>(targetId);

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

                // assert
                result.Should().BeFalse();
            }
            public void ShouldBeEqualWithIEntityIdWhenValuesAndEntitiesAreEqual()
            {
                // arrange
                var targetId               = Faker.Random.Long();
                var stronglyTypedId        = new LongFor <Order>(targetId);
                var anotherStronglyTypedId = new IdFor <Order, long>(targetId);

                // act
                var result = stronglyTypedId != anotherStronglyTypedId;

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

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

                // assert
                result.Should().BeTrue();
            }
Exemplo n.º 13
0
            public void ShouldNotBeEqualWithIEntityIdWhenSecondNull()
            {
                // arrange
                var targetId        = Guid.NewGuid();
                var stronglyTypedId = new IdFor <Order, Guid>(targetId);
                IEntityId <Order, Guid> anotherStronglyTypedId = null;

                // act
                var result = stronglyTypedId != anotherStronglyTypedId;

                // assert
                result.Should().BeTrue();
            }
Exemplo n.º 14
0
            public void ShouldBeEqualWithIEntityIdWhenValuesAndEntitiesAreEqual()
            {
                // arrange
                var targetId        = Guid.NewGuid();
                var stronglyTypedId = new IdFor <Order, Guid>(targetId);
                IEntityId <Order, Guid> anotherStronglyTypedId = new GuidFor <Order>(targetId);

                // act
                var result = stronglyTypedId != anotherStronglyTypedId;

                // assert
                result.Should().BeFalse();
            }
            public void ShouldBeEqualWhenValuesAndEntitiesAreEqual()
            {
                // arrange
                var targetId               = Guid.NewGuid();
                var stronglyTypedId        = new IdFor <Order, Guid>(targetId);
                var anotherStronglyTypedId = new IdFor <Order, Guid>(targetId);

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

                // assert
                result.Should().BeTrue();
            }
Exemplo n.º 16
0
            public void ShouldNotProvideSameHashCodeWhenValuesAreDifferent()
            {
                // arrange
                var stronglyTypedId        = new IdFor <Order, Guid>(Guid.NewGuid());
                var anotherStronglyTypedId = new IdFor <Order, Guid>(Guid.NewGuid());

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

                // assert
                hashCode1.Should().NotBe(hashCode2);
            }
Exemplo n.º 17
0
            public void ShouldNotBeEqualWithIEntityIdWhenFirstNull()
            {
                // arrange
                IdFor <Order, Guid>     stronglyTypedId        = null;
                IEntityId <Order, Guid> anotherStronglyTypedId = new GuidFor <Order>(Guid.NewGuid());

                ;

                // act
                var result = stronglyTypedId != anotherStronglyTypedId;

                // assert
                result.Should().BeTrue();
            }
Exemplo n.º 18
0
            public void ShouldNotProvideSameHashCodeWhenEntitiesAreDifferent()
            {
                // arrange
                var targetId               = Guid.NewGuid();
                var stronglyTypedId        = new IdFor <Order, Guid>(targetId);
                var anotherStronglyTypedId = new IdFor <PricePosition, Guid>(targetId);

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

                // assert
                hashCode1.Should().NotBe(hashCode2);
            }
Exemplo n.º 19
0
            public void ShouldProvideSameHashCodeWhenValuesAndEntitiesAreEqual()
            {
                // arrange
                var targetId               = Guid.NewGuid();
                var stronglyTypedId        = new IdFor <Order, Guid>(targetId);
                var anotherStronglyTypedId = new IdFor <Order, Guid>(targetId);

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

                // assert
                hashCode1.Should().Be(hashCode2);
            }