Exemple #1
0
        public ActionResult AddCharacter(string name, int classid, int raceid)
        {
            RPGSQLContext rpgsqlContext = new RPGSQLContext();
            RPGRepository repo          = new RPGRepository(rpgsqlContext);

            repo.AddCharacter((int)Session["UserID"], classid, raceid, name);
            _loginview.UserID = (int)Session["UserID"];
            return(RedirectToAction("Character", _loginview));
        }
        public void Add_Character()
        {
            RPGSQLContext context  = new RPGSQLContext();
            RPGRepository repo     = new RPGRepository(context);
            string        testname = "TestUserCharacter9";

            //Add a test character to userid 2, with class and race id 2 and the name TestUserCharacter
            repo.AddCharacter(2, 2, 2, testname);

            //Get the character from the database
            Character        character  = null;
            List <Character> characters = repo.GetCharactersFromUser(2);

            foreach (Character chars in characters)
            {
                if (chars.Name == testname)
                {
                    character = chars;
                }
            }

            //Character info test
            Assert.AreEqual(testname, character.Name);
        }