Exemplo n.º 1
0
        public IIdentityEquatable GetExpectedValue(IIdentityEquatable other)
        {
            if (this.Expected == null)
            {
                throw new Exception("Expected property must be set on wildcard");
            }

            if (!(other is T))
            {
                throw new Exception("Cannot get expected value when actual value is a different type");
            }

            return(this.Expected((T)other));
        }
        private static bool AreEntitiesEqual(IIdentityEquatable possibleWildcard, IIdentityEquatable standardEntity)
        {
            if (!possibleWildcard.IdentityEquals(standardEntity))
            {
                return(false);
            }

            var wildcardEntity = possibleWildcard as IWildcardEntity;

            if (wildcardEntity != null && standardEntity != null)
            {
                if (wildcardEntity.EntityType != standardEntity.GetType())
                {
                    // Ensure we do not try to get expected value using an actual value of different type.
                    return(false);
                }

                possibleWildcard = wildcardEntity.GetExpectedValue(standardEntity);
            }

            return(Equals(possibleWildcard, standardEntity));
        }