public void SetUp()
        {
            alex = new CmsUser(){Login = "******", Password = "******"};

            var userData = new Mock<IUserData>();
            userData.Setup(x => x.Login("alex", "password")).Returns(alex);
            UserService userService = new UserService(userData.Object);
            controller = new AccountController(userService);
        }
        public AccountControllerTests()
        {
            client = A.Fake<IIwsClient>();

            controller = new AccountController(A.Fake<IOAuthClient>(), A.Fake<IAuthenticationManager>(), client,
                A.Fake<IUserInfoClient>());

            var request = A.Fake<HttpRequestBase>();
            var context = A.Fake<HttpContextBase>();

            A.CallTo(() => request.Url).Returns(new Uri("https://test.com"));
            A.CallTo(() => context.Request).Returns(request);

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            controller.Url = new UrlHelper(new RequestContext(context, new RouteData()));
        }
        public async Task ActivateUserAccount_WithInvalidToken_ReturnsAccountActivationFailedView()
        {
            // Arrange
            IWeeeClient apiClient = A.Fake<IWeeeClient>();
            A.CallTo(() => apiClient.User.ActivateUserAccountEmailAsync(A<ActivatedUserAccountData>._))
                .Returns(false);
            
            IWeeeAuthorization weeeAuthorization = A.Dummy<IWeeeAuthorization>();
            IExternalRouteService externalRouteService = A.Dummy<IExternalRouteService>();

            var controller = new AccountController(() => apiClient, weeeAuthorization, externalRouteService);
            
            // 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);
        }
Exemplo n.º 4
0
 public void GetMembershipCreateStatusResultTextMethodReturnsOtherErrorText()
 {
     var controller = new AccountController(new DataManager(null, null, null, null, null));
     string result = controller.GetMembershipCreateStatusResultText(MembershipCreateStatus.InvalidPassword);
     Assert.AreEqual("Неизвестная ошибка", result);
 }
Exemplo n.º 5
0
 public void GetMembershipCreateStatusResultTextMethodReturnsDuplicateUserNameErrorText()
 {
     var controller = new AccountController(new DataManager(null, null, null, null, null));
     string result = controller.GetMembershipCreateStatusResultText(MembershipCreateStatus.DuplicateUserName);
     Assert.AreEqual("Пользователь с таким именем уже существует", result);
 }
Exemplo n.º 6
0
        AccountController CreateAccountController(IAccountRepository repo = null, NameValueCollection form = null)
        {
            var mockAccountRepository = new Mock<IAccountRepository>();
            mockAccountRepository.Setup(r => r.GetAll()).Returns(new List<User>());

            var controller = new AccountController(repo ?? mockAccountRepository.Object);

            var roles = new string[]{"SuperUser"};
            SetupControllerContext(controller, roles,form);

            return controller;
        }
 private static AccountController GetAccountController()
 {
     AccountController controller = new AccountController()
     {
         FormsService = new MockFormsAuthenticationService(),
         MembershipService = new MockMembershipService()
     };
     controller.ControllerContext = new ControllerContext()
     {
         Controller = controller,
         RequestContext = new RequestContext(new MockHttpContext(), new RouteData())
     };
     return controller;
 }