public void TestAddBookToMedia() { AddBooks(1); MediaLibContainer context = ContextHelper <MediaLibContainer> .GetCurrentContext(); Book book = context.MediaSet.OfType <Book>().First <Book>(); int expectedBookId = book.Id; MediaController mediaController = new MediaController(); FormCollection collection = new FormCollection(); collection["ctl00$MainContent$BookTitle"] = book.Title; collection["ctl00$MainContent$BookTitleOriginal"] = book.OriginalTitle; collection["GenreList"] = book.Genre; collection["ctl00$MainContent$Isbn"] = book.Isbn; ViewResult result = mediaController.AddBookToDb(collection, fakeUser) as ViewResult; Book b = MediaService.Instance.GetBookById(book.Id); addedMedia.Add(b); Assert.IsNotNull(b); Assert.AreEqual(expectedBookId, b.Id); }