Exemplo n.º 1
0
        public void issue_book_does_not_issue_book_to_student()
        {
            //given
            int randomStudentId = rnd.Next(1, TestData.Students.Count);
            var student         = TestData.Students.Where(s => s.StudentId == randomStudentId).First();
            int randomBookId    = rnd.Next(1, TestData.IssuedBooks.Count);
            var book            = TestData.Books.Where(s => s.BookId == randomBookId).First();

            moqStudentService.Setup(m => m.GetStudent(It.IsAny <int>())).Returns(student);
            moqBookService.Setup(m => m.GetBook(It.IsAny <int>())).Returns(book);
            var sut = new BookStoreService(moqStudentService.Object, moqBookService.Object, moqBookAllocationService.Object);

            //when
            var result = sut.IssueBook(student.StudentId, book.BookId);

            //then
            Assert.IsInstanceOfType(result, typeof(bool));
            Assert.IsFalse(result);
            moqStudentService.Verify(v => v.GetStudent(It.IsAny <int>()), Times.Once);
            moqBookService.Verify(v => v.GetBook(It.IsAny <int>()), Times.Once);
        }