/// <summary> /// Creates a <see cref="Mock{T}"/> with the specified <see cref="MockStyle"/> and additional types. /// </summary> /// <typeparam name="T">The type of mock to create.</typeparam> /// <param name="mockStyle"></param> /// <param name="additionalTypesToMock"></param> /// <returns></returns> public Mock <T> CreateMock <T>(MockStyle mockStyle, params Type[] additionalTypesToMock) where T : class { return(CreateMock <T>(DefinedAs.OfStyle(mockStyle).Implementing(additionalTypesToMock))); }
/// <summary> /// Creates a <see cref="Mock{T}"/> with the specified name and <see cref="MockStyle"/>. /// </summary> /// <typeparam name="T">The type of mock to create.</typeparam> /// <param name="name"></param> /// <param name="mockStyle"></param> /// <returns></returns> public Mock <T> CreateMock <T>(string name, MockStyle mockStyle) where T : class { return(CreateMock <T>(DefinedAs.Named(name).OfStyle(mockStyle))); }
/// <summary> /// Creates a <see cref="Mock{T}"/> with the specified name. /// </summary> /// <typeparam name="T">The type of mock to create.</typeparam> /// <param name="name"></param> /// <returns></returns> public Mock <T> CreateMock <T>(string name) where T : class { return(CreateMock <T>(DefinedAs.Named(name))); }
/// <summary> /// Creates a <see cref="Mock{T}"/> with the specified <see cref="MockStyle"/>. /// </summary> /// <typeparam name="T">The type of mock to create.</typeparam> /// <param name="mockStyle"></param> /// <returns></returns> public Mock <T> CreateMock <T>(MockStyle mockStyle) where T : class { return(CreateMock <T>(DefinedAs.OfStyle(mockStyle))); }
/// <summary> /// Creates a new dynamic mock of the specified type. /// </summary> /// <typeparam name="TMockedType">The type to mock.</typeparam> /// <param name="mockStyle">Specifies how the mock object should behave when first created.</param> /// <param name="constructorArgs">The arguments for the constructor of the class to be mocked. /// Only applicable when mocking classes with non-default constructors.</param> /// <returns>A dynamic mock for the specified type.</returns> public TMockedType CreateInstance <TMockedType>(MockStyle mockStyle, params object[] constructorArgs) { return(CreateInstance <TMockedType>(DefinedAs.OfStyle(mockStyle).WithArgs(constructorArgs))); }
/// <summary> /// Creates a new named dynamic mock of the specified type and allows the style /// of the mock to be specified. /// </summary> /// <param name="mockedType">The type to mock.</param> /// <param name="name">A name for the mock that will be used in error messages.</param> /// <param name="mockStyle">Specifies how the mock object should behave when first created.</param> /// <param name="constructorArgs">The arguments for the constructor of the class to be mocked. /// Only applicable when mocking classes with non-default constructors.</param> /// <returns>A named mock.</returns> internal object NewMock(Type mockedType, string name, MockStyle mockStyle, params object[] constructorArgs) { return(DefinedAs.Named(name).OfStyle(mockStyle).WithArgs(constructorArgs).Create(mockedType, this, _currentMockObjectFactory)); }
/// <summary> /// Creates a new dynamic mock of the specified type. /// </summary> /// <typeparam name="TMockedType">The type to mock.</typeparam> /// <param name="constructorArgs">The arguments for the constructor of the class to be mocked. /// Only applicable when mocking classes with non-default constructors.</param> /// <returns>A dynamic mock for the specified type.</returns> public TMockedType CreateInstance <TMockedType>(params object[] constructorArgs) { return(CreateInstance <TMockedType>(DefinedAs.WithArgs(constructorArgs))); }
/// <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="name">The name of the mock.</param> /// <returns>A dynamic mock for the specified type.</returns> public TMockedType CreateInstance <TMockedType>(string name) { return(CreateInstance <TMockedType>(DefinedAs.Named(name))); }
/// <summary> /// Creates a <see cref="Mock{T}"/> using the specified arguments. /// </summary> /// <typeparam name="T">The type of mock to create.</typeparam> /// <param name="name"></param> /// <param name="mockStyle"></param> /// <param name="additionalTypesToMock"></param> /// <param name="constructorArguments"></param> /// <returns></returns> public Mock <T> CreateMock <T>(string name, MockStyle mockStyle, Type[] additionalTypesToMock, params object[] constructorArguments) where T : class { return(CreateMock <T>(DefinedAs.Named(name).OfStyle(mockStyle).Implementing(additionalTypesToMock).WithArgs(constructorArguments))); }
/// <summary> /// Creates a <see cref="Mock{T}"/> with the specified constructor arguments. /// </summary> /// <typeparam name="T">The type of mock to create.</typeparam> /// <param name="constructorArguments"></param> /// <returns></returns> public Mock <T> CreateMock <T>(params object[] constructorArguments) where T : class { return(CreateMock <T>(DefinedAs.WithArgs(constructorArguments))); }
/// <summary> /// Creates a <see cref="Mock{T}"/> of the primary type and the specified additional types /// </summary> /// <typeparam name="T">The type of mock to create.</typeparam> /// <param name="additionalTypesToMock"></param> /// <returns></returns> public Mock <T> CreateMock <T>(params Type[] additionalTypesToMock) where T : class { return(CreateMock <T>(DefinedAs.Implementing(additionalTypesToMock))); }