public void ObjectId_of_int_correctly_serializes_to_null() { GenericObjectId <int> id = null; var s = JsonConvert.SerializeObject(id); s.Should().Be("null"); }
public void Two_ObjectIds_have_the_same_HashCode_if_created_with_the_same_underlying_value() { Guid guid = Guid.NewGuid(); var id1 = new GenericObjectId <Guid>(guid); var id2 = new GenericObjectId <Guid>(guid); id1.GetHashCode().Should().Be(id2.GetHashCode()); }
public void An_ObjectId_is_equal_to_a_primitive_of_its_underlying_value() { var i = Any.Int(); var objectId = new GenericObjectId <int>(i); (objectId == i).Should().BeTrue(); // (i == objectId).Should().BeTrue(); (objectId.Equals(i)).Should().BeTrue(); // (i.Equals(objectId)).Should().BeTrue(); (Equals(objectId, i)).Should().BeTrue(); }
public void Two_instances_of_ObjectId_having_the_same_underlying_value_are_equal() { Guid guid = Guid.NewGuid(); var id1 = new GenericObjectId <Guid>(guid); var id2 = new GenericObjectId <Guid>(guid); (id1 == id2).Should().BeTrue(); (id2 == id1).Should().BeTrue(); (id1.Equals(id2)).Should().BeTrue(); (id2.Equals(id1)).Should().BeTrue(); (Equals(id1, id2)).Should().BeTrue(); }
public void ToString_returns_Value_ToString() { var id = new GenericObjectId <string>("hello"); id.ToString().Should().Be("hello"); }