コード例 #1
0
        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));
        }
コード例 #2
0
        public void MakeSureICanGetMyPoems()
        {
            //Arrange
            PoemRepository repo = new PoemRepository(mock_context.Object);

            //Act
            List <Poem> myPoetry = repo.GetPoems();

            //Assert
            Assert.AreEqual(myPoetry.Count, 3);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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())));
        }
コード例 #5
0
 // GET api/<controller>
 public IEnumerable <Poem> Get()
 {
     return(repo.GetPoems());
 }