示例#1
0
        public void IfNoPreferredSkillsAvailableJustChooseOne()
        {
            var generic    = CharacterTestTemplates.WithSkills(new string[] { "Climb" });
            var skillFocus = SkillFocus.CreateForTesting();

            generic.Add(skillFocus);
            Assert.Equal(3, generic.SkillRanks.GetScore("Climb"));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            SkillFocus skillFocus = db.SkillFocus.Find(id);

            db.SkillFocus.Remove(skillFocus);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
        public void TracksTheSkillThatWasSelected()
        {
            var generic    = CharacterTestTemplates.WithSkills(new string[] { "Climb" });
            var skillFocus = SkillFocus.CreateForTesting();

            generic.Add(skillFocus);
            Assert.Equal(generic.SkillRanks.GetSkill("Climb"), skillFocus.CharacterSkill);
        }
示例#4
0
        public void SkillFocusThatHasSkillSelectedAlwaysPicksThatSkill()
        {
            var skillFocus = SkillFocus.CreateForTesting();

            skillFocus.SetSkillFocus("Climb");
            var genericCharacter = CharacterTestTemplates.WithSkills(new string[] { "Climb", "Swim" });

            genericCharacter.Add(skillFocus);
            Assert.Equal(3, genericCharacter.SkillRanks.GetScore("Climb"));
        }
示例#5
0
        public void CopyingSpecificSkillFocusRetainsSkill()
        {
            var skillFocus = SkillFocus.CreateForTesting();

            skillFocus.SetSkillFocus("Climb");
            var copy = skillFocus.Copy() as SkillFocus;

            Assert.Equal("Climb", copy.SkillName);
            Assert.Equal("Skill Focus(Climb)", copy.Name);
        }
示例#6
0
        public void SelectsASkillBasedOnStrategyForSkillsToProvideABonusTo()
        {
            var generic = CharacterTestTemplates.WithSkills(new string[] { "Climb", "Swim", "Perception" });

            generic.Get <CharacterStrategy>().FavoredSkills.AddEntry("Swim", 1000);
            var skillFocus = SkillFocus.CreateForTesting();

            generic.Add(skillFocus);

            Assert.Equal(3, generic.SkillRanks.GetScore("Swim"));
        }
示例#7
0
 public ActionResult Edit([Bind(Include = "SkillFocusId,EmployeeId,SkillId,Startdate")] SkillFocus skillFocus)
 {
     if (ModelState.IsValid)
     {
         db.Entry(skillFocus).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "Firstname", skillFocus.EmployeeId);
     ViewBag.SkillId    = new SelectList(db.Skills, "SkillId", "Skillname", skillFocus.SkillId);
     return(View(skillFocus));
 }
示例#8
0
        public void AddingASecondSkillFocusSelectsADifferentSkill()
        {
            var genericCharacter = CharacterTestTemplates.WithSkills(new string[] { "Climb", "Swim" });
            var skillFocus       = SkillFocus.CreateForTesting();

            genericCharacter.Add(skillFocus);
            var skillFocus2 = SkillFocus.CreateForTesting();

            genericCharacter.Add(skillFocus2);
            Assert.Equal(3, genericCharacter.SkillRanks.GetScore("Climb"));
            Assert.Equal(3, genericCharacter.SkillRanks.GetScore("Swim"));
        }
示例#9
0
        // GET: SkillFocus/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SkillFocus skillFocus = db.SkillFocus.Find(id);

            if (skillFocus == null)
            {
                return(HttpNotFound());
            }
            return(View(skillFocus));
        }
示例#10
0
        // GET: SkillFocus/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SkillFocus skillFocus = db.SkillFocus.Find(id);

            if (skillFocus == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "Firstname", skillFocus.EmployeeId);
            ViewBag.SkillId    = new SelectList(db.Skills, "SkillId", "Skillname", skillFocus.SkillId);
            return(View(skillFocus));
        }
示例#11
0
        public void AtTenRanksProvideABonusOfSix()
        {
            var generic = CharacterTestTemplates.WithSkills(new string[] { "Climb", "Swim", "Perception" });

            generic.Get <CharacterStrategy>().FavoredSkills.AddEntry("Swim", 1000);

            var skillFocus = SkillFocus.CreateForTesting();

            generic.Add(skillFocus);

            Repeat.Times(10,
                         generic.SkillRanks.GetSkill("Swim").AddRank
                         );

            Assert.Equal(16, generic.SkillRanks.GetScore("Swim"));
        }
示例#12
0
        public ActionResult Create([Bind(Include = "SkillFocusId,EmployeeId,SkillId,Startdate")] SkillFocus skillFocus)
        {
            if (ModelState.IsValid)
            {
                var      userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
                var      currentUser = userManager.FindById(User.Identity.GetUserId());
                Employee employee    = db.Employees.Where(i => i.ApplicationUserId == currentUser.Id).FirstOrDefault();
                skillFocus.EmployeeId = employee.EmployeeId;
                skillFocus.Startdate  = DateTime.Now;
                skillFocus.Employee   = employee;
                skillFocus.Skill      = db.Skills.Find(skillFocus.SkillId);
                employee.ISkillFocus.Add(skillFocus);
                db.SkillFocus.Add(skillFocus);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "Firstname", skillFocus.EmployeeId);
            ViewBag.SkillId    = new SelectList(db.Skills, "SkillId", "Skillname", skillFocus.SkillId);
            return(View(skillFocus));
        }
        public void SkillRanks10_Bonus6()
        {
            // Arrange
            Func <byte> untypedBonusCalc = null;            // we'll test this later

            var character = Mock.Of <ICharacter>();

            var mockSkill = new Mock <ISkill>();

            mockSkill.Setup(s => s.Ranks)
            .Returns(10);
            mockSkill.Setup(s => s.UntypedBonuses.Add(It.IsAny <Func <byte> >()))
            .Callback <Func <byte> >(f => untypedBonusCalc = f);

            SkillFocus skillFocus = new SkillFocus(mockSkill.Object);

            // Act
            skillFocus.ApplyTo(character);

            // Assert
            Assert.AreEqual(6, untypedBonusCalc(),
                            "Applying Skill Focus to a character should introduce an untyped bonus calculation to its associated skill.  If the skill has at least 10 ranks, the untyped bonus should be +6.");
        }
示例#14
0
        /// <summary>
        /// Saves the character class level.
        /// </summary>
        /// <returns>CharacterSkill Object</returns>
        public CharacterSkill SaveCharacterSkill()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "InsertUpdate_CharacterSkill";
                command.Parameters.Add(dbconn.GenerateParameterObj("@CharacterID", SqlDbType.Int, CharacterID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@SkillID", SqlDbType.Int, SkillID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@HalfLevel", SqlDbType.Int, HalfLevel.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@AbilityMod", SqlDbType.Int, AbilityMod.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Trained", SqlDbType.Int, Trained.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@SkillFocus", SqlDbType.Int, SkillFocus.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Miscellaneous", SqlDbType.Int, Miscellaneous.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@FeatTalentMod", SqlDbType.Int, FeatTalentMod.ToString(), 0));
                result = command.ExecuteReader();

                result.Read();
                SetReaderToObject(ref result);
            }
            catch
            {
                Exception e = new Exception();
                this._insertUpdateOK = false;
                this._insertUpdateMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this);
        }
示例#15
0
        public void ShouldStartBeNamedProperlyAndStuff()
        {
            var skillFocus = SkillFocus.CreateForTesting();

            Assert.Equal("Skill Focus", skillFocus.Name);
        }