public int CompareTo(object obj) { Order order = obj as Order; if (order == null) { throw new System.ArgumentNullException(); } return(OrderId.CompareTo(order.OrderId)); }
public void ShouldProvide1WhenCompareToNullObject() { // arrange var targetId = Guid.NewGuid(); var stronglyTypedId = new OrderId(targetId); // act var result = stronglyTypedId.CompareTo((object)null); // assert result.Should().Be(1); }
public void ShouldProvide0ForSameEntityId() { // arrange var targetId = Guid.NewGuid(); var stronglyTypedId = new OrderId(targetId); // act var result = stronglyTypedId.CompareTo((IEntityId <Order, Guid>)stronglyTypedId); // assert result.Should().Be(0); }
public void ShouldProvide0ForSameBaseId() { // arrange var targetId = Guid.NewGuid(); var stronglyTypedId = new OrderId(targetId); var anotherStronglyTypedId = new OrderId(targetId); // act var result = stronglyTypedId.CompareTo(anotherStronglyTypedId); // assert result.Should().Be(0); }
public void ShouldThrowWhenCompareWithNoEntityId() { // arrange var targetId = Guid.NewGuid(); var stronglyTypedId = new OrderId(targetId); var someObject = new Order(); // act Func <int> act = () => stronglyTypedId.CompareTo(someObject); // assert act.Should().Throw <ArgumentException>(); }
public void ShouldProvideSameResultAsBaseIdsDoForObject() { // arrange var stronglyTypedId = new OrderId(Guid.NewGuid()); var anotherStronglyTypedId = new OrderId(Guid.NewGuid()); // act var result1 = stronglyTypedId.CompareTo((object)anotherStronglyTypedId); var result2 = anotherStronglyTypedId.CompareTo((object)stronglyTypedId); var baseResult1 = stronglyTypedId.Value.CompareTo(anotherStronglyTypedId.Value); var baseResult2 = anotherStronglyTypedId.Value.CompareTo(stronglyTypedId.Value); // assert result1.Should().Be(baseResult1); result2.Should().Be(baseResult2); }