moq (software)

from Wikipedia, the free encyclopedia
moq
Basic data

Current  version 4.7.142
( October 11, 2017 )
programming language .NET programming languages
category Test - Framework
License BSD license
https://github.com/moq/moq4#moq

moq is a free ( BSD license ) program library for creating mock objects for unit tests in .NET programming languages .

history

moq was originally developed by Clarius, Manas and InSTEDD.

The developers with the most commits are Jeremy Meng, stakx, and Daniel Cazzulino.

use

The q instead of ck in the name is intended to indicate the possibility of configuring mock objects with a LINQ- oriented syntax. Alternatively, setup methods are also available. Both configuration options work with Lambda functions .

moq can be used with both interfaces and classes, e.g. B. for .NET Framework objects during unit testing of ASP.NET MVC applications.

example

A mock object for the fictitious interface IVersion is tested for status and behavior after a method call has been configured with parameter and return values.

// Setup mock for notional IVersion interface
IVersion version = Mock.Of<IVersion>(x => x.Exists("4.7.142") == true);
// Assert the returned state
Assert.IsTrue(version.Exists("4.7.142"));
// Optionally verify mock interaction
Mock.Get(version).Verify(x => x.Exists("4.7.142"), Times.Exactly(1));

This example was programmed in C # and verified with Visual Studio 2015 .

distribution

moq has been downloaded more than 74 million times as a NuGet package since February 9, 2011.

See also

Web links

Individual evidence

  1. README.md Who? (English), accessed September 27, 2017
  2. Github contributors , accessed September 27, 2017
  3. Daniel Cazzulino's blog: Linq to Mocks is finally born (English), accessed on September 27, 2017
  4. Peter Vogel: Ensure Consistent Testing with Mock Objects and Moq, Visual Studio Magazine (English), accessed September 27, 2017
  5. NuGet Packages Gallery , accessed October 18, 2019