Exemple #1
0
        public void UserMockTest()
        {
            UserMock userMock = new UserMock(books.ToList(), accounts.ToList(), comments.ToList());

            //Бронировка
            userMock.BusyBook(2, 1);
            Assert.IsTrue(userMock.GetBook(2).IsBusy);
            Assert.AreEqual(userMock.GetBook(2).IdAccount, 1);

            userMock.TakeOff(2);
            Assert.IsFalse(userMock.GetBook(2).IsBusy);

            //Поиск книг
            Assert.AreEqual(userMock.FindBookByAuthor("author1").First().Id, 1);
            Assert.AreEqual(userMock.FindBookByPublisher("publisher2").First().Id, 2);
            Assert.AreEqual(userMock.FindBookByGenre("genre1").First().Id, 1);

            //Комментарии
            Comment comment1 = new Comment()
            {
                IdBook = 1, TextComment = "comment1"
            };
            Comment comment2 = new Comment()
            {
                IdBook = 1, TextComment = "comment2"
            };

            userMock.MakeComment(comment1);
            userMock.MakeComment(comment2);
            Assert.AreEqual(userMock.ReadComments(1).ElementAt(0).TextComment, "comment1");

            //Книги и аккаунты
            Assert.AreEqual(userMock.AllBooks.Count(), 2);

            Assert.IsNull(userMock.GetBook(100));
            Assert.AreEqual(userMock.GetBook(2).Title, "title2");

            Assert.AreEqual(userMock.MyAccount("22", "name2").Email, "email2");
        }