public void Can_Add_Word() { // Get a CollectionId to add to var collectionId = 2; // Make word var word = new Word() { UserId = 1, CollectionId = 2, MwWordId = "12345", Name = "Added", LastViewed = DateTime.Now - TimeSpan.FromDays(15) }; // Instantiate Word Repo var repo = new WordRepository(_context); // Get a count of words in Collection var originalCount = repo.GetByCollectionId(collectionId).Count; // Add items repo.Add(word); // Get new count var newCount = repo.GetByCollectionId(collectionId).Count; // New count should be +1 original Assert.True(newCount == originalCount + 1); }
public void Can_Delete_Single_Word() { // Get a CollectionId to remove from var collectionId = 1; // Instantiate Word Repo var repo = new WordRepository(_context); // Get a count of words in Collection var originalCount = repo.GetByCollectionId(collectionId).Count; // Get the words from the Collection var words = repo.GetByCollectionId(collectionId); // Delete word repo.DeleteSingleWord(words[0]); // Get new count var newCount = repo.GetByCollectionId(collectionId).Count; // New count should be -1 original Assert.True(newCount == originalCount - 1); }
public void Can_Get_All_Words_By_Collection() { // Get a valid Collection Id var id = 1; // Instantiate Word Repo var repo = new WordRepository(_context); // Get count of all words var count = repo.GetByCollectionId(id).Count; // Should have retrieved three items Assert.True(count == 3); }
public void Can_Delete_All_Words_From_Collection() { // Get a CollectionId to remove from var collectionId = 1; // Instantiate Word Repo var repo = new WordRepository(_context); // Get a count of words in Collection var originalCount = repo.GetByCollectionId(collectionId).Count; // Get the words from the Collection var words = repo.GetByCollectionId(collectionId); // Delete all words repo.DeleteAllWordsInCollection(words); // Get new count var newCount = repo.GetByCollectionId(collectionId).Count; // New count should be -1 original Assert.True(newCount == originalCount - 3); }