Created
July 11, 2012 21:48
-
-
Save waldyrfelix/3093834 to your computer and use it in GitHub Desktop.
Mock de um UnitOfWork retornada a partir de um ServiceLocator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Mock<IUnitOfWork> MockUnitOfWork() | |
{ | |
var mockUnitOfWork = new Mock<IUnitOfWork>(); | |
var mockUnitOfWorkFactory = new Mock<IUnitOfWorkFactory>(); | |
mockUnitOfWorkFactory.Setup(_ => _.Criar()) | |
.Returns(mockUnitOfWork.Object); | |
var mockServiceLocator = new Mock<IServiceLocator>(); | |
mockServiceLocator.Setup(_ => _.GetInstance<IUnitOfWorkFactory>()) | |
.Returns(mockUnitOfWorkFactory.Object); | |
ServiceLocator.SetLocatorProvider(() => mockServiceLocator.Object); | |
return mockUnitOfWork; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment