public void MakeSureIHaveContext() { PoemRepository repo = new PoemRepository(); PoemContext actual_context = repo.Context; Assert.IsInstanceOfType(actual_context, typeof(PoemContext)); }
public void CanICreateAnInstanceOfRepository() { //Arrange PoemRepository repo = new PoemRepository(); //Act //Assert Assert.IsNotNull(repo); }
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 MakeSureICanGetPoemByTitle() { //Arrange PoemRepository repo = new PoemRepository(mock_context.Object); //Act string title = "Lovely Day"; Poem found_poem = repo.FindPoemByTitle(title); //Assert Assert.AreEqual(found_poem.Title, title); }
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()))); }
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 Initialize() { mock_context = new Mock <PoemContext>(); mockPoetry = new Mock <DbSet <Poem> >(); myPoems = new List <Poem>() { new Poem { Title = "Lovely Day", Author = "Blade", Words = "I was thinking about coming to your house, but I heard you live with a mouse", Id = 78 }, new Poem { Title = "Allergies", Author = "Biti", Words = "Walking through the trees. I feel a breeze. Oh I gotta sneeze. Achoo! Allergies", Id = 95 }, new Poem { Title = "Another One", Author = "Biti", Words = "You Got Flex", Id = 102 } }; //Fake repo = new PoemRepository(mock_context.Object); ConnectMocksToDatastore(); }