Example #1
0
        public void ArmorRetrieveTest()
        {
            // Arrange
            var expectedArmor = new Armor(1)
            {
                Defense     = 1,
                Description = "Protects the wearer",
                Encumbrance = 2,
                Name        = "Heavy Clothing",
                Price       = 200,
                Rarity      = 1,
                Soak        = 1
            };
            // Act
            var actualArmorRepository = new ArmorRepository();
            var actualArmor           = actualArmorRepository.Retrieve(1);

            // Assert
            Assert.AreEqual(expectedArmor.Defense, actualArmor.Defense);
            Assert.AreEqual(expectedArmor.Description, actualArmor.Description);
            Assert.AreEqual(expectedArmor.Encumbrance, actualArmor.Encumbrance);
            Assert.AreEqual(expectedArmor.Name, actualArmor.Name);
            Assert.AreEqual(expectedArmor.Price, actualArmor.Price);
            Assert.AreEqual(expectedArmor.Rarity, actualArmor.Rarity);
            Assert.AreEqual(expectedArmor.Soak, actualArmor.Rarity);
        }
Example #2
0
        // TODO: Add Character and Armor Controllers
        public static void ConfigureControllers(DataContext context, Mapper mapper, out PotionController potionController, out WeaponController weaponController, out ArmorController armorController, out CharacterController characterController)
        {
            PotionRepository    potionRepository    = new PotionRepository(context);
            WeaponRepository    weaponRepository    = new WeaponRepository(context);
            ArmorRepository     armorRepository     = new ArmorRepository(context);
            CharacterRepository characterRepository = new CharacterRepository(context);

            potionController    = new PotionController(potionRepository, mapper);
            weaponController    = new WeaponController(weaponRepository, mapper);
            armorController     = new ArmorController(armorRepository, mapper);
            characterController = new CharacterController(characterRepository, mapper);
        }
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public ActionResult List()
 {
     try
     {
         var list = ArmorRepository.List();
         return(Json(list, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { Success = false }, JsonRequestBehavior.AllowGet));
     }
 }
        /// <summary>
        /// Saves the specified armor.
        /// </summary>
        /// <param name="armor">The armor.</param>
        /// <returns></returns>
        public ActionResult Save(Armor armor)
        {
            try
            {
                var typeId  = Int32.Parse(Request.Form["TypeId"]);
                var availId = Int32.Parse(Request.Form["AvailabilityId"]);

                armor.Type         = ArmorTypeRepository.Retrieve(typeId);
                armor.Availability = ArmorAvailabilityRepository.Retrieve(availId);

                ArmorRepository.Save(armor);
                ArmorRepository.Session.Flush();
                return(Json(new { Success = true, Message = "Armor saved successfully" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Success = false, Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Example #5
0
 public ArmorController(ArmorRepository repo, Mapper mapper)
 {
     _repo   = repo;
     _mapper = mapper;
 }