Ejemplo n.º 1
0
        public void Update_WhenDeckNotFound_Throws()
        {
            var deckHash       = "deckHash";
            var hashidsMock    = new Mock <IHashids>();
            var deckRepository = new DeckRepository(DbContextFactory.Create(), hashidsMock.Object);

            Assert.Throws <DeckNotFoundException>(() => deckRepository.Update(deckRepository.GetDeck(deckHash)));
        }
 public ActionResult Edit(DeckViewModel deckVM)
 {
     if (ModelState.IsValid)
     {
         repo.Update(ToModel(deckVM));
         repo.Save();
         return(RedirectToAction("Index"));
     }
     return(View(deckVM));
 }
Ejemplo n.º 3
0
        public void Update_WhenDeckFound_Updates()
        {
            var deckHash    = "deckHash";
            var hashidsMock = new Mock <IHashids>();

            hashidsMock.Setup(x => x.Encode(It.IsAny <int>())).Returns(deckHash);
            var deckRepository = new DeckRepository(DbContextFactory.Create(), hashidsMock.Object);

            deckRepository.Insert(new Deck());

            var deck = deckRepository.GetDeck(deckHash);

            deck.Remaining = 21;
            deckRepository.Update(deck);

            Assert.That(deckRepository.GetDeck(deckHash).Remaining == 21);
        }