Exemple #1
0
            public void ShouldProvide0ForSameId()
            {
                // arrange
                var targetId        = Guid.NewGuid();
                var stronglyTypedId = new GuidFor <Order>(targetId);

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

                // assert
                result.Should().Be(0);
            }
Exemple #2
0
            public void ShouldThrowWhenCompareWithNoEntityId()
            {
                // arrange
                var stronglyTypedId = new GuidFor <Order>(Guid.NewGuid());
                var someObject      = new Order();

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

                // assert
                act.Should().Throw <ArgumentException>();
            }
Exemple #3
0
            public void ShouldProvide1WhenCompareToNullEntityId()
            {
                // arrange
                var targetId        = Guid.NewGuid();
                var stronglyTypedId = new GuidFor <Order>(targetId);


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

                // assert
                result.Should().Be(1);
            }
Exemple #4
0
            public void ShouldProvideSameResultAsBaseIdsDoForEntityId()
            {
                // arrange
                var stronglyTypedId        = new GuidFor <Order>(Guid.NewGuid());
                var anotherStronglyTypedId = new GuidFor <Order>(Guid.NewGuid());

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

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

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