private AccountController AccountController() { var request = GetFakeRequest(); var context = A.Fake<HttpContextBase>(); A.CallTo(() => context.Request).Returns(request); var controller = new AccountController( () => apiClient, authenticationManager, externalRouteService, weeeAuthorization); controller.ControllerContext = new ControllerContext(context, new RouteData(), controller); controller.Url = new UrlHelper(new RequestContext(controller.HttpContext, new RouteData())); return controller; }
public async Task ActivateUserAccount_WithInvalidToken_ReturnsAccountActivationFailedView() { // Arrange IWeeeClient apiClient = A.Fake<IWeeeClient>(); A.CallTo(() => apiClient.User.ActivateUserAccountEmailAsync(A<ActivatedUserAccountData>._)) .Returns(false); IExternalRouteService externalRouteService = A.Dummy<IExternalRouteService>(); IAuthenticationManager authenticationManager = A.Dummy<IAuthenticationManager>(); IWeeeAuthorization weeeAuthorization = A.Dummy<IWeeeAuthorization>(); var controller = new AccountController(() => apiClient, authenticationManager, externalRouteService, weeeAuthorization); // Act var result = await controller.ActivateUserAccount(new Guid("EF565DF2-DC16-4589-9CE4-B29568B3E274"), "code"); // Assert ViewResult viewResult = result as ViewResult; Assert.NotNull(viewResult); Assert.Equal("AccountActivationFailed", viewResult.ViewName); }