Advertisement
Guest User

Untitled

a guest
Feb 20th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public void TestMethod1()
  2. {
  3.  
  4. //Make the virtual context that has User database set and Course database set
  5. var context = new TestNLDS_V_Context();
  6.  
  7. //make test user with empry courses list
  8. ICollection<Book> book_collection = new Collection<Book>();
  9. User test = new User { ID = 1, username = "test", password = "test2", email = "test@test.com", phone = 1231231234, selfDescription = "why", courses = course_collection };
  10.  
  11. //add user and course to virtual database set
  12. context.Users.Add(test);
  13.  
  14. context.Books.Add(new Book { jasiu, etc, etc });
  15.  
  16. //Gain the controller
  17. var controller = new UsersController(context, test);
  18. controller.set_currentUser(test); //current user = test
  19.  
  20. string[] test_array = { "2" };
  21.  
  22. //add book to the user
  23. var result = controller.AddBooks(test_array);
  24.  
  25. Assert.IsNotNull(result);
  26.  
  27. //check it is not null
  28. Assert.IsNotNull(test.books);
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement