// Make a controller and pass it back. // Only use this if you do not need repository functionality in the unit test. private static SsoController SetupControllerWithEmptyRepoMocks() { var accountRepository = new Mock <IAccountRepository>(); var partialAccountRepository = new Mock <IPartialAccountRepository>(); var jwtRepository = new Mock <IJAccessTokenRepository>(); var saltRepository = new Mock <ISaltRepository>(); var partialAccountSaltRepository = new Mock <IPartialAccountSaltRepository>(); var expiredAccessTokenRepository = new Mock <IExpiredAccessTokenRepository>(); // TODO: @Scott Add business logic dependency to the controller setup test cases. var controller = new SsoController(); return(controller); }
// Creates a new mocked Controller private static void SetupDummyController() { // This version uses a mock UrlHelper. // Arrange var mockAccountRepo = new Mock <IAccountRepository>(); var MockJwtRepo = new Mock <IJAccessTokenRepository>(); SsoController controller = new SsoController { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; string locationUrl = "https://localhost:44311/Sso/Login"; // Create the mock and set up the Link method, which is used to create the Location header. // The mock version returns a fixed string. var mockUrlHelper = new Mock <UrlHelper>(); mockUrlHelper.Setup(x => x.Link(It.IsAny <string>(), It.IsAny <object>())).Returns(locationUrl); controller.Url = mockUrlHelper.Object; }