0% found this document useful (0 votes)
77 views4 pages

NonProfit Access Control and Payment Tests

The document contains code snippets for four different methods being tested: 1. A method to block a NonProfit by setting its access level to -1, with a test that asserts the access level is correctly set to -1. 2. A method to submit a payment if the access level is 3, with a test that asserts payment is submitted when access level is 3. 3. A method to cancel a current auction by setting the auction to null, with a test that asserts the auction is correctly set to null. 4. A method to check for a valid user by comparing credentials, with tests that assert true for valid credentials and false for invalid credentials.

Uploaded by

abdielcabrera
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views4 pages

NonProfit Access Control and Payment Tests

The document contains code snippets for four different methods being tested: 1. A method to block a NonProfit by setting its access level to -1, with a test that asserts the access level is correctly set to -1. 2. A method to submit a payment if the access level is 3, with a test that asserts payment is submitted when access level is 3. 3. A method to cancel a current auction by setting the auction to null, with a test that asserts the auction is correctly set to null. 4. A method to check for a valid user by comparing credentials, with tests that assert true for valid credentials and false for invalid credentials.

Uploaded by

abdielcabrera
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Kevin: Method tested: /** * Blocks a NonProfit. */ public void blockNonProfit() { super.

setMy_accessLevel(-1); } The test: @Before public void setUp() throws Exception { Address address1 = new Address("123 crasy St", "", "B", "Miami", "FL", "33125"); NonProfit nonProfit = new NonProfit("Abdiel", "Cabrera", "WTF", "23431", null, address1, "asdvsf@[Link]"); nonProfit.setMy_accessLevel(3); [Link](); blocked_nonProfit = nonProfit.getMy_accessLevel(); } @Test public void testblockNonProfit() { assertEquals("Block access level", blocked_nonProfit, -1); }

Abdiel: Method tested: /** * Submit Payment. * * @return TRUE if payment Submitted. * FALSE otherwise. */ public boolean submitPayment() { if (super.getMy_accessLevel() == 3) return true; else return false; } The test: @Before public void setUp() throws Exception { Address address1 = new Address("123 crasy St", "", "B", "Miami", "FL", "33125"); NonProfit nonProfit = new NonProfit("Abdiel", "Cabrera", "WTF", "23431", null, address1, "asdvsf@[Link]"); nonProfit.setMy_accessLevel(3); [Link](); blocked_nonProfit = nonProfit.getMy_accessLevel(); } @Test public void testsubmitPayment() { assertTrue("Was the payment submitted?", [Link]()); }

Bob: Method tested: /** * Cancels the current Auction. */ public void cancelAuction() { my_currentAuction = null; } The test: @Before public void setUp() throws Exception { Address address1 = new Address("123 crasy St", "", "B", "Miami", "FL", "33125"); NonProfit nonProfit = new NonProfit("Abdiel", "Cabrera", "WTF", "23431", null, address1, "asdvsf@[Link]"); nonProfit.setMy_accessLevel(3); [Link](); blocked_nonProfit = nonProfit.getMy_accessLevel(); } @Test public void testcancelAuction(){ // the auction has been cancelled and therefore it is null assertNull(nonProfit.getMy_currentAuction()); }

Eric: Method tested: /** * Checks for a valid User. * * @param the_userName The userName of the User. * @param the_password The password of the User. * @return TRUE if credentials accepted and FALSE otherwise. */ public boolean isValidUser(String the_userName, String the_password) { if (the_userName.equals(this.my_userName) && the_password.equals(my_password)) return true; else return false; } The test: private Bidder user = new Bidder("Abdiel", "Cabrera", "username", "password", null, null, null); @Test public void testisValidUser() { assertTrue("Testing CreditCard1", [Link]("username", "password")); assertFalse("Testing CreditCard2", [Link]("fake", "fake")); }

You might also like