Skip to content

CreateObjectOfType is a helper framework for reduce the amount of boilerplate code required to test objects using DI and Moq.

Notifications You must be signed in to change notification settings

andrewboudreau/CreateObjectOfType

Repository files navigation

CreateObjectOfType<>

CreateObjectOfType is a helper framework for reduce the amount of boilerplate code required to test objects using DI and Moq.

  • Simplifies to the testing process of objects with changing or numerous constructor parameters.
  • Designed to work in conjunction with Moq testing framework.
  • Statisfies an objects constructor dependencies with Moq instances created on the fly.
  • Supports both Strict and Loose behaviors.
  • Keep your tests clean and understandable.

USAGE EXAMPLE

[TestMethod()]
public void Delete_PassInId_ReturnsRedirect()
{
	//Arrange
	var A = CreateObjectOfType<MyController>.WithMocks(MockBehavior.Strict);

	A.MockOf<IBackendService>()
		.Setup(r => r.DeleteSomething(It.IsAny<Guid>()))
		.Verifiable();

	//Act
	var controller = A.Target;
	var result = controller.Delete(Guid.NewGuid());

	//Assert
	A.Verify();
	Assert.IsTrue(result is RedirectToRouteResult);
}

About

CreateObjectOfType is a helper framework for reduce the amount of boilerplate code required to test objects using DI and Moq.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages