Exemplo n.º 1
0
        /// <summary>
        /// Creates a <see cref="Mock{T}"/> instance.  Use the <see cref="DefinedAs"/> class as a parameter.
        /// </summary>
        /// <typeparam name="T">The type of mock to create.</typeparam>
        /// <param name="mockDefinition"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method gives the developer the most control when creating the mock because they can
        /// specify all parts of the mock definition.
        /// </remarks>
        public Mock <T> CreateMock <T>(IMockDefinition mockDefinition) where T : class
        {
            if (mockDefinition == null)
            {
                throw new ArgumentNullException("mockDefinition");
            }

            return(new Mock <T>(mockDefinition.Create(typeof(T), this, _currentMockObjectFactory), this));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new dynamic mock of the specified type using the supplied definition.
 /// </summary>
 /// <typeparam name="TMockedType">The type to mock.</typeparam>
 /// <param name="definition">An <see cref="IMockDefinition"/> to create the mock from.</param>
 /// <returns>A dynamic mock for the specified type.</returns>
 public TMockedType CreateInstance <TMockedType>(IMockDefinition definition)
 {
     return((TMockedType)definition.Create(typeof(TMockedType), this, _currentMockObjectFactory));
 }