Esempio n. 1
0
        // GET: Accessories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Accessory accessory = dbAccessory.FindById(Convert.ToInt32(id));

            if (accessory == null)
            {
                return(HttpNotFound());
            }
            return(View(accessory));
        }
        public void IsRepositoryFindsAccessory()
        {
            var id     = 1;
            var result = AccessoryRepo.FindById(Convert.ToInt32(id));

            Assert.AreEqual("Banaan", result.Name);
        }
Esempio n. 3
0
        public void AccessoriesEdit()
        {
            Accessory accessory = new Accessory();

            accessory.Name  = "Jeroen";
            accessory.Price = 100;

            AccessoryRepo.Add(accessory);

            accessory.Name = "Chris";

            var result = accessoriesController.Edit(accessory) as RedirectToRouteResult;

            Assert.AreEqual("Chris", AccessoryRepo.FindById(accessory.Id).Name);
            Assert.AreEqual("Index", result.RouteValues["Action"]);
            Assert.IsNotNull(result.ToString());

            AccessoryRepo.Remove(accessory.Id);
        }