Esempio n. 1
0
        public WishList.Data.WishList GetWishList(int ownerId)
        {
            if (_repository.GetUsers().WithId(ownerId) == null)
            {
                throw new ArgumentException("User with id " + ownerId + " does not exist - cannot get wish list!");
            }

            return(new WishList.Data.WishList(ownerId, _repository.GetWishes().ForUser(ownerId).ToList()));
        }
Esempio n. 2
0
        public void Can_Edit_Wish()
        {
            //Create a new wish to edit
            Wish wish = repository.SaveWish(new Wish
            {
                Name        = "EditTestWish",
                Description = "Some description",
                Owner       = repository.GetUsers().WithId(1),
                LinkUrl     = "http://www.google.com"
            });
            Wish wishToEdit = new Wish {
                Name = "Changed name", Description = "Changed description", LinkUrl = "http://www.microsoft.com"
            };
            IPrincipal user = new GenericPrincipal(new GenericIdentity("User 1", "Forms"), null);

            var result = controller.Edit(wish.Id, wishToEdit, user) as RedirectToRouteResult;

            Assert.IsNotNull(result, "Result was null or not redirecttorouteresult");
            Assert.AreEqual("Show", result.RouteValues["action"]);
            Assert.AreEqual("List", result.RouteValues["controller"]);
            Assert.AreEqual(wish.Owner.Name, result.RouteValues["id"]);

            Wish loadedWish = repository.GetWishes().WithId(wish.Id);

            Assert.AreEqual(wishToEdit.Name, loadedWish.Name);
            Assert.AreEqual(wishToEdit.Description, loadedWish.Description);
            Assert.AreEqual(wishToEdit.LinkUrl, loadedWish.LinkUrl);
        }