public void Remove_WhenDeckNotFound_Throws() { var deckHash = "deckHash"; var hashidsMock = new Mock <IHashids>(); var deckRepository = new DeckRepository(DbContextFactory.Create(), hashidsMock.Object); Assert.Throws <DeckNotFoundException>(() => deckRepository.Remove(deckHash)); }
public void Remove_WhenDeckFound_RemovesIt() { 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 { }); deckRepository.Remove(deckHash); Assert.That(deckRepository.GetDecks().Count() == 0); }
public ActionResult DeleteConfirmed(int id) { repo.Remove(id); repo.Save(); return(RedirectToAction("Index")); }