Ejemplo n.º 1
0
        public void CheckValidationPassWhenBothCredentialsHasData()
        {
            var mockAuthenticationService = new MockAuthenticationService();
            var loginViewModel            = new LoginViewModel(mockAuthenticationService);

            loginViewModel.UserName.Value = "foo";
            loginViewModel.Password.Value = "bar";

            loginViewModel.LoginCommand.Execute(null);

            Assert.False(loginViewModel.HasInvalidCredentials);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage LoginDemo(LoginProfile loginProfile)
        {
            MockAuthenticationService demoService = new MockAuthenticationService();
            UserProfile user = demoService.GetUser(loginProfile.Username, loginProfile.Password);

            if (user == null)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Invalid User", Configuration.Formatters.JsonFormatter));
            }
            else
            {
                AuthenticationModule authentication = new AuthenticationModule();
                string token = authentication.GenerateTokenForUser(user.UserName, user.UserId);
                return(Request.CreateResponse(HttpStatusCode.OK, token, Configuration.Formatters.JsonFormatter));
            }
        }
Ejemplo n.º 3
0
        public void DoesTriggerWorkOnStart()
        {
            FakeDteTrigger            fakeDteTrigger            = new FakeDteTrigger();
            MockUserStateService      mockUserStateService      = new MockUserStateService();
            MockAuthenticationService mockAuthenticationService = new MockAuthenticationService();

            mockAuthenticationService.RaiseLoginComplete();
            mockUserStateService.SetUserState(new UserStateInfoResponse(1, "ae", new DateTime(2000, 12, 12),
                                                                        TimeWarpState.None, new DateTime(2012, 12, 12),
                                                                        TimeSpan.Zero, 0, false, TimeWarpAgent.VisualStudio));
            VsWorkStarter vsWorkStarter = new VsWorkStarter(mockUserStateService, mockAuthenticationService, fakeDteTrigger);

            vsWorkStarter.StartWorkAsync();

            Assert.AreEqual(1, mockUserStateService.StartWorkCalled);
        }
Ejemplo n.º 4
0
        public void CheckValidationFailsWhenOnlyPasswordHasData()
        {
            var mockAuthenticationService = new MockAuthenticationService();
            var loginViewModel            = new LoginViewModel(mockAuthenticationService);

            loginViewModel.Password.Value = "bar";

            bool isValid = loginViewModel.Validate();

            Assert.False(isValid);
            Assert.NotNull(loginViewModel.Password.Value);
            Assert.Null(loginViewModel.UserName.Value);
            Assert.True(loginViewModel.Password.IsValid);
            Assert.False(loginViewModel.UserName.IsValid);
            Assert.Empty(loginViewModel.Password.Errors);
            Assert.NotEmpty(loginViewModel.UserName.Errors);
        }
Ejemplo n.º 5
0
        public void CheckValidationFailsWhenWrongCredentials()
        {
            var mockAuthenticationService = new MockAuthenticationService();

            Assert.Throws <AuthenticationException>(() => mockAuthenticationService.Login("foo", "papitas"));
        }