public void MakeSureICanAddAPoem() { //Arrange PoemRepository repo = new PoemRepository(mock_context.Object); Poem newPoem = new Poem() { Title = "Test", Author = "Superman", Words = "This is that stuff right here dog" }; //Act repo.AddPoem(newPoem); int numberOfPoems = repo.GetPoems().Count; List <Poem> myPoems = repo.GetPoems(); //Assert Assert.IsTrue(myPoems.Contains(newPoem)); }
public void MakeSureICanGetMyPoems() { //Arrange PoemRepository repo = new PoemRepository(mock_context.Object); //Act List <Poem> myPoetry = repo.GetPoems(); //Assert Assert.AreEqual(myPoetry.Count, 3); }
public void MakeSureICanGetPoemByID() { //Arrange PoemRepository repo = new PoemRepository(mock_context.Object); //Act int myId = 102; Poem found_poetry = repo.FindPoemById(myId); List <Poem> my_poetry = repo.GetPoems(); Assert.IsTrue(my_poetry.Contains(found_poetry)); }
public void MakeSureICanGetPoemsByAuthor() { //Arrange PoemRepository repo = new PoemRepository(mock_context.Object); //Act string author = "Biti"; List <Poem> found_poetry = repo.FindPoemByAuthor(author); List <Poem> my_poetry = repo.GetPoems(); //Assert Assert.IsTrue(my_poetry.Contains(found_poetry.FirstOrDefault(p => p.Author.ToLower() == author.ToLower()))); }
// GET api/<controller> public IEnumerable <Poem> Get() { return(repo.GetPoems()); }