Advertisement
Guest User

Untitled

a guest
Mar 5th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. [TestMethod]
  2. public async void TestBookController()
  3. {
  4. //Make the virtual context that has User database set and Course database set
  5. var context = new TestNLDS_V_Context();
  6. var testA = new Book
  7. {
  8. ID = 2,
  9. name = "Vergil's story",
  10. description = "A Son of Sparda",
  11. chapters = new List<Chapter>(),
  12. authors = new List<Author>(),
  13. listingDate = DateTime.Parse("2012-09-01")
  14.  
  15.  
  16. };
  17. var testB = new Book
  18. {
  19. ID = 15,
  20. name = "jasiu",
  21. description = "jasiu",
  22. chapters = new List<Chapter>(),
  23. authors = new List<Author>(),
  24. listingDate = DateTime.Parse("2012-09-03")
  25.  
  26. };
  27.  
  28. //make test user with empry courses list
  29. ICollection<Book> book_collection = new Collection<Book>();
  30.  
  31. ICollection<Course> course_collection = new Collection<Course>();
  32. User test = new User { ID = 1, username = "test", password = "test2", email = "test@test.com", phone = 1231231234, selfDescription = "why", courses = course_collection, books = book_collection };
  33.  
  34. //add user and book to virtual database set
  35. context.Users.Add(test);
  36.  
  37. context.Books.Add(testA);
  38. context.Books.Add(testB);
  39.  
  40.  
  41. //Gain the controller
  42. var controller = new UsersController(context, test);
  43. controller.set_currentUser(test);
  44. var ctrlr = new BooksController();
  45. ActionResult y = ctrlr.Create();
  46. ActionResult x = await ctrlr.Delete(1);
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement