コード例 #1
0
ファイル: LoginViewTests.cs プロジェクト: yi520/bit-framework
        public virtual void InValidLoginMustShowsAnError()
        {
            using (BitOwinTestEnvironment testEnvironment = new BitOwinTestEnvironment(new TestEnvironmentArgs {
                UseRealServer = true
            }))
            {
                using (RemoteWebDriver driver = testEnvironment.Server.GetWebDriver(new RemoteWebDriverOptions {
                    Uri = @"core/connect/authorize?scope=openid profile user_info&client_id=Test&redirect_uri=http://localhost/SignIn&response_type=id_token token&state={}&nonce=SgPoeilE1Tub", ClientSideTest = false
                }))
                {
                    new WebDriverWait(driver, TimeSpan.FromSeconds(3))
                    .Until(ExpectedConditions.ElementExists(By.Name("loginForm")));

                    driver.FindElementByName("username").SendKeys("InValidUserName");
                    driver.FindElementByName("password").SendKeys("InValidPassword");
                    driver.FindElementByName("login").Click();

                    new WebDriverWait(driver, TimeSpan.FromSeconds(3))
                    .Until(ExpectedConditions.ElementExists(By.Name("error")));

                    Assert.AreEqual("Login failed", driver.FindElementByName("error").GetAttribute("innerText"));
                }

                TestUserService testUserService = TestDependencyManager.CurrentTestDependencyManager.Objects
                                                  .OfType <TestUserService>()
                                                  .Single();

                A.CallTo(() => testUserService.AuthenticateLocalAsync(A <LocalAuthenticationContext> .That.Matches(cntx => cntx.UserName == "InValidUserName" && cntx.Password == "InValidPassword")))
                .MustHaveHappened(Repeated.Exactly.Once);
            }
        }
コード例 #2
0
        public InviteNewUserAccountCommandTests()
        {
            _dbHelper         = new DbHelper <ExampleDbContext>().RunMigrations();
            _handlerDbContext = _dbHelper.GetDbContext();

            _emailSender         = new TestEmailSender();
            _httpContextAccessor = new TestHttpContextAccessor();
            _testUserService     = new TestUserService();

            var authEmailSender = new AuthEmailSender(_httpContextAccessor, _emailSender, GetIdentityProviderConfiguration(), GetApplicationConfiguration());

            _handler   = new InviteNewUserAccountCommandHandler <ExampleDbContext>(_handlerDbContext, authEmailSender, _testUserService);
            _validator = new InviteNewUserAccountCommandValidator <ExampleDbContext>(_handlerDbContext);
        }
コード例 #3
0
 /// <summary>
 /// Initialize all the services for use.
 /// </summary>
 protected override void InitServices()
 {
     Logger      = new UnityLogger();
     InputPoller = new UnityInputPoller();
     UserService = new TestUserService();
 }