public void Setup() { _registerViewModel = new RegisterViewModel(); _emptyRegisterViewModel = new RegisterViewModel(); _existingRegisterViewModel = new RegisterViewModel { PendingUserId = ExistingGuid }; _mockCommandDispatcher = new Mock<ICommandDispatcher>(); _mockCommandDispatcher .Setup(m => m.Dispatch(new RegisterCommand())) .Verifiable(); _mockQueryDispatcher = new Mock<IQueryDispatcher>(); _mockQueryDispatcher .Setup(m => m.Dispatch(It.IsAny<GetPendingUserDetailsByGuidQuery>())) .Returns((GetPendingUserDetailsByGuidQuery query) => TestData.PendingUsersList.First(p => p.Id == query.PendingUserId).ToRegisterViewModel()); //_getGetUserProfileByUserNameQuery = new GetUserProfileByUserNameQuery {UserName = "******"}; //_mockQueryDispatcher // .Setup(m => m.Dispatch(_getGetUserProfileByUserNameQuery)) // .Returns(new UserViewModel() { UserName = "******" } ); //_mockQueryDispatcher // .Setup(m => m.Dispatch(new GetNewUserDetailsByGuidQuery() { Id = ExistingGuid })) // .Returns(TestData.PendingUsersList); _controller = new AccountController(_mockCommandDispatcher.Object, _mockQueryDispatcher.Object); }
public void Given_CAN_When_Query_Is_Valid_then_return_ClientEntryPointURL() { string dummyUrl = "http://dummyurl"; _mockQueryDispatcher .Setup(m => m.Dispatch<EntryPointURLModel>(It.IsAny<IQuery<EntryPointURLModel>>())) .Returns(new EntryPointURLModel(dummyUrl)); AccountController controller = new AccountController(_mockCommandDispatcher.Object, _mockQueryDispatcher.Object); GetClientEntryPointQuery qry = new GetClientEntryPointQuery(); qry.CAN = "DEMO002"; IHttpActionResult actionResult = controller.GetEntryPointForClient( qry ); Assert.IsInstanceOf<OkNegotiatedContentResult<EntryPointURLModel>>(actionResult); var contentResult = actionResult as OkNegotiatedContentResult<EntryPointURLModel>; Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual( dummyUrl, contentResult.Content.URL ); }