예제 #1
0
        static void Main(string[] args)
        {
            IAuthDb authDb = new AuthDb();
            var     pepper = "changme";

            var accountManager = new StandardAccountManager <SampleUser, SampleLogin>(authDb, pepper);

            accountManager.CreateUserWithLogin("*****@*****.**", "password1");

            var result = accountManager.ValidLogin("*****@*****.**", "password1");

            if (result.ResultType == LoginResult <SampleUser> .Type.success)
            {
                Console.WriteLine($"User {result.User.PrimaryEmailAddress} logged in OK");
            }
            else if (result.ResultType == LoginResult <SampleUser> .Type.failiure)
            {
                Console.WriteLine($"Unable to login");
            }
            else
            {
                throw new Exception("An unexpected value was returned from the AccountManger");
            }

            Console.ReadLine();
        }
예제 #2
0
        public void AccountManagerCreatesUserTest()
        {
            var authDb = new TestAuthDb();

            ILoginManager <TestUser> loginManager = new LoginManager <TestUser, TestLogin>(authDb, DefaultSitePepper, _userNameValidator);
            IUserManager <TestUser>  userManager  = new UserManager <TestUser>(authDb, new EmailAddressValidator());

            IAccountManager <TestUser> accountManager = new StandardAccountManager <TestUser, TestLogin>(userManager, loginManager);

            string userName = "******";
            string password = "******";

            accountManager.CreateUserWithLogin(userName, password);

            Assert.AreEqual(LoginResult <TestUser> .Type.success, accountManager.ValidLogin(userName, password).ResultType, "Newly created user account failed to login");
        }