public void User_Can_Get_A_Single_Collection_By_Id() { // Set an expected collection to get that's in the db var expectedCollection = new Collection() { UserId = 1, CategorizationId = 1, Categorization = new Categorization() { Id = 1, Type = "Part of Speech" }, Name = "Monsters", Description = "Monsters and related words It becomes.", Pinned = false }; // Get a Collection Id that is in the Db int collectionId = 3; // Instantiate CollectionRepo var repo = new CollectionRepository(_context); // Get Collection by its Id var actualCollection = repo.GetByCollectionId(collectionId); // Two objects should have the same name. Was unable to test if Assert.Equal because Repo returns all the Objects from the FKs Assert.True(expectedCollection.Name == actualCollection.Collection.Name); }
public void User_Can_Edit_Collection() { // Instantiate CollectionRepo var repo = new CollectionRepository(_context); // Get an Collection from the Db var collectionToUpdate = repo.GetByCollectionId(1); collectionToUpdate.Collection.Name = "You GOT UPDATED!"; collectionToUpdate.Collection.Description = "AND YOU GOT UPDATED!"; // Attempt to update repo.Update(collectionToUpdate.Collection); // Retrieve item from db to see if updates occurred var updatedCollection = repo.GetByCollectionId(1); // The new names should match Assert.True(updatedCollection.Collection.Name == collectionToUpdate.Collection.Name); }