Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void TestMethod1()
- {
- //Make the virtual context that has User database set and Course database set
- var context = new TestNLDS_V_Context();
- //make test user with empry courses list
- ICollection<Book> book_collection = new Collection<Book>();
- User test = new User { ID = 1, username = "test", password = "test2", email = "test@test.com", phone = 1231231234, selfDescription = "why", courses = course_collection };
- //add user and course to virtual database set
- context.Users.Add(test);
- context.Books.Add(new Book { jasiu, etc, etc });
- //Gain the controller
- var controller = new UsersController(context, test);
- controller.set_currentUser(test); //current user = test
- string[] test_array = { "2" };
- //add book to the user
- var result = controller.AddBooks(test_array);
- Assert.IsNotNull(result);
- //check it is not null
- Assert.IsNotNull(test.books);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement