public void Insert_InsertsGivenDeck() { var hashidsMock = new Mock <IHashids>(); var deckRepository = new DeckRepository(DbContextFactory.Create(), hashidsMock.Object); Assert.That(deckRepository.GetDecks().Count() == 0); deckRepository.Insert(new Deck { }); Assert.That(deckRepository.GetDecks().Count() == 1); }
public void GetDecks_WhenNoDecksFound_ReturnsEmptySet() { var hashidsMock = new Mock <IHashids>(); var deckRepository = new DeckRepository(DbContextFactory.Create(), hashidsMock.Object); var decks = deckRepository.GetDecks(); Assert.IsEmpty(decks); }
public void GetDecks_WhenDecksFound_ReturnsAll() { var hashidsMock = new Mock <IHashids>(); var deckRepository = new DeckRepository(DbContextFactory.Create(), hashidsMock.Object); deckRepository.Insert(new Deck { }); var decks = deckRepository.GetDecks(); Assert.AreEqual(decks.Count(), 1); }
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); }