Ejemplo n.º 1
0
        /// <summary>
        ///     Called when a value is read from the indexer.
        ///     This implementation logs before and after the value has been read, along with any exceptions thrown.
        /// </summary>
        /// <param name="mockInfo">Information about the mock through which the value is read.</param>
        /// <param name="key">The indexer key used.</param>
        /// <returns>The value being read.</returns>
        public override TValue Get(IMockInfo mockInfo, TKey key)
        {
            _logContext.LogBeforeIndexerGet(mockInfo, key);
            TValue result;

            try
            {
                result = base.Get(mockInfo, key);
            }
            catch (Exception exception)
            {
                _logContext.LogIndexerGetException(mockInfo, exception);
                throw;
            }

            _logContext.LogAfterIndexerGet(mockInfo, result);
            return(result);
        }