Ejemplo n.º 1
0
        public void パスワード生成シナリオ()
        {
            var _viewModel = new PasswordGeneratorViewModel();


            // パスワードの種類を選ぶ
            _viewModel.AlphabetCheck = true;
            _viewModel.NumberCheck   = true;

            // パスワードの文字数を選ぶ
            _viewModel.PasswordLength = 10;

            // パスワード生成を押す
            _viewModel.Create();


            Assert.AreEqual(10, _viewModel.PasswordText.Length);


            var _viewModel2 = new PasswordGeneratorViewModel();

            // パスワードの種類を選ぶ
            _viewModel2.AlphabetCheck = true;
            _viewModel2.NumberCheck   = true;

            // パスワードの文字数を選ぶ
            _viewModel2.PasswordLength = 8;

            // パスワード生成を押す
            _viewModel2.Create();
            Assert.AreEqual(8, _viewModel2.PasswordText.Length);
        }
        public ActionResult Password(PasswordGeneratorViewModel newPassword, string suggestion, string submit)
        {
            if (!string.IsNullOrEmpty(suggestion))
            {
                ViewBag.items = PasswordGen(newPassword);
                return(PartialView("Password"));
            }

            else if (!string.IsNullOrEmpty(submit) && ModelState.IsValid)
            {
            }

            return(View());
        }
Ejemplo n.º 3
0
        public void パスワードの長さを一つも選択しなかった場合の例外処理()
        {
            Assert.AreEqual(10, 10);


            var _viewModel = new PasswordGeneratorViewModel();

            // パスワードの種類を選ぶ
            _viewModel.AlphabetCheck = true;
            _viewModel.NumberCheck   = false;

            // パスワード生成を押す
            var ex = AssertEx.Throws <InputException>(() => _viewModel.Create());

            ex.Message.Is("パスワードの長さが選択されていません");
        }
Ejemplo n.º 4
0
        public void パスワードタイプを一つも選択しなかった場合の例外処理()
        {
            var _viewModel = new PasswordGeneratorViewModel();


            // パスワードの種類を選ぶ
            _viewModel.AlphabetCheck = false;
            _viewModel.NumberCheck   = false;

            // パスワードの文字数を選ぶ
            _viewModel.PasswordLength = 8;


            // パスワード生成を押す
            var ex = AssertEx.Throws <InputException>(() => _viewModel.Create());

            ex.Message.Is("パスワードタイプが選択されていません");
        }
        private List <string> PasswordGen(PasswordGeneratorViewModel newPassword)
        {
            //Store user input from textboxes
            string lName    = newPassword.LastName.Replace(" ", string.Empty);
            string bYear    = newPassword.BirthYear.ToString().Replace(" ", string.Empty);
            string favColor = newPassword.FavoriteColor.Replace(" ", string.Empty);

            //Creating and storing the passwords
            string password1 = lName.Insert(lName.Length / 2, favColor);
            string password2 = string.Concat(favColor, bYear, lName.Remove(1));
            string password3 = bYear.Insert(bYear.Length / 2, favColor);
            string password4 = string.Concat(ReverseString(bYear), lName);
            string password5 = string.Concat(lName.Remove(1), favColor, favColor, favColor);

            //Put the created passwords into an array
            string[] passwords = new string[] { password1, password2, password3, password4, password5 };

            List <string> items = new List <string>
            {
                password1, password2, password3, password4, password5
            };

            return(items);
        }
Ejemplo n.º 6
0
        public MainPage()
        {
            BindingContext = new PasswordGeneratorViewModel();

            InitializeComponent();
        }