public void HasDefaultIdentifierValue_WhenIdentifierIsGuid() { var objectInfo = ObjectInfo.For(typeof(CustomerWithGuidIdentifier)); var customer = new CustomerWithGuidIdentifier(); customer.Id = Guid.Empty; Assert.True(objectInfo.HasDefaultIdentifierValue(customer)); customer.Id = Guid.NewGuid(); Assert.False(objectInfo.HasDefaultIdentifierValue(customer)); }
public void HasDefaultIdentifierValue_ThrowsMappingException_IfInstanceIsIncorrectType() { var objectInfo = ObjectInfo.For(typeof(Customer)); var instance = new CustomerWithGuidIdentifier(); var exception = Assert.Throws <MappingException>( () => objectInfo.HasDefaultIdentifierValue(instance)); Assert.Equal( string.Format(ExceptionMessages.PocoObjectInfo_TypeMismatch, typeof(CustomerWithGuidIdentifier).Name, objectInfo.ForType.Name), exception.Message); }
public void HasDefaultIdentifierValue_ThrowsMappingException_IfInstanceIsIncorrectType() { var objectInfo = ObjectInfo.For(typeof(Customer)); var instance = new CustomerWithGuidIdentifier(); var exception = Assert.Throws<MappingException>( () => objectInfo.HasDefaultIdentifierValue(instance)); Assert.Equal( string.Format(ExceptionMessages.PocoObjectInfo_TypeMismatch, typeof(CustomerWithGuidIdentifier).Name, objectInfo.ForType.Name), exception.Message); }