public void AddBookStateTest()
        {
            int beforeSize          = context.bookStates.Count;
            var beforeLastBookState = context.bookStates.Last();
            var bookStateToAdd      = new BookState()
            {
                DateOfPurchase = new DateTimeOffset(2017, 5, 21, 00, 00, 00, new TimeSpan(1, 0, 0)),
                Book           = new Book()
                {
                    Isbn        = "9788327152305",
                    Title       = "Człowiek nietoperz",
                    Author      = "Jo Nesbo",
                    ReleaseYear = 2014
                }
            };

            service.AddBookState(bookStateToAdd);
            int afterSize          = context.bookStates.Count;
            var afterLastBookState = context.bookStates.Last();

            // check sizes
            Assert.AreNotEqual(beforeSize, afterSize);

            // check if last books aren't equal
            Assert.AreNotEqual(beforeLastBookState, afterLastBookState);

            // check if the book is in the list
            Assert.IsTrue(context.bookStates.Contains(bookStateToAdd));
        }
Exemplo n.º 2
0
        public void GetAllBooksTest()
        {
            DataService.AddBookState(BookState);
            IEnumerator <Book> enumerator = DataService.GetAllBooks().GetEnumerator();
            int size = 0;

            while (enumerator.MoveNext())
            {
                size++;
                Assert.AreEqual(Book, enumerator.Current);
            }
            Assert.AreEqual(1, size);
        }